class Message

Schema Information

Table name: messages

id                :integer          not null, primary key
user_id           :integer
chat_id           :integer
content           :string
image             :string
image_orientation :integer
message_type      :string
sent              :boolean
read              :boolean
created_at        :datetime         not null
updated_at        :datetime         not null

Indexes

index_messages_on_chat_id  (chat_id)
index_messages_on_user_id  (user_id)

Private Instance Methods

update_chat_generic_data() click to toggle source
# File lib/templates/chat/migration-models/message.rb, line 36
def update_chat_generic_data
  chat.update_column(:last_message, content)
end
user_in_chat() click to toggle source
# File lib/templates/chat/migration-models/message.rb, line 40
def user_in_chat
  chat.users.includes(user)
end