Clean up the controller

This commit is contained in:
David Heinemeier Hansson
2025-04-11 16:49:55 +02:00
parent f2811803d3
commit a8aa2c4f80
2 changed files with 18 additions and 17 deletions
+6
View File
@@ -3,9 +3,15 @@ module Card::Messages
included do
has_many :messages, -> { chronologically }, dependent: :destroy
has_many :comments, through: :messages, source: :messageable
after_save :capture_draft_comment
end
def comments
# FIXME: I could have sworn there was a way to declare this as a association?
Comment.joins(:message).where(messages: { card_id: id })
end
def capture(messageable)
messages.create! messageable: messageable
end