Simlpe callback is actually enough

Since the Comment already knows about the card.
This commit is contained in:
David Heinemeier Hansson
2025-04-12 11:45:34 +02:00
parent f2c2b0492e
commit e4efe446e6
3 changed files with 9 additions and 12 deletions
+9 -6
View File
@@ -11,12 +11,7 @@ class Comment < ApplicationRecord
scope :belonging_to_card, ->(card) { joins(:message).where(messages: { card_id: card.id }) }
before_destroy :cleanup_events
# Called when a new comment is captured as a message during creation
def created_via_message
card.watch_by creator
card.track_event :commented, comment_id: id
end
after_create_commit :creator_watches_card, :track_commenting_on_card
def to_partial_path
"cards/#{super}"
@@ -28,4 +23,12 @@ class Comment < ApplicationRecord
# Delete events that reference directly in particulars
Event.where(particulars: { comment_id: id }).destroy_all
end
def creator_watches_card
card.watch_by creator
end
def track_commenting_on_card
card.track_event :commented, comment_id: id
end
end