Clean up the controller
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user