class Chatmessage < ApplicationRecord
  belongs_to :chatroom
  belongs_to :user
  include GravatarImageTag

  def photo
    user = User.find(self.user_id)
    if user.custom_photo.present?
      return "/usericons/#{user.custom_photo}"
    else
      return gravatar_image_url(user.email, { :secure => true, :s => 1024 } )
    end
  end
end
