Files
fizzy/app/models/message.rb
T
2024-10-28 10:27:50 -06:00

13 lines
509 B
Ruby

class Message < ApplicationRecord
belongs_to :bubble, touch: true
delegated_type :messageable, types: Messageable::TYPES, inverse_of: :message, dependent: :destroy
scope :chronologically, -> { order created_at: :asc, id: :desc }
# FIXME: Will be made redundant when we compute activity and comment count at write time. See commit.
scope :left_joins_messageable, ->(messageable_type) do
joins "LEFT OUTER JOIN #{messageable_type} ON messages.messageable_id = #{messageable_type}.id"
end
end