From 0031ce34ea85ef22391211acf23b64d4d0135fdc Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 12 Apr 2025 11:46:17 +0200 Subject: [PATCH] Correct order --- app/models/comment.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 1d9ca3038..5818f72a9 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -10,20 +10,14 @@ class Comment < ApplicationRecord # FIXME: Not a fan of this. Think all references to comment should come directly from the message. scope :belonging_to_card, ->(card) { joins(:message).where(messages: { card_id: card.id }) } - before_destroy :cleanup_events after_create_commit :creator_watches_card, :track_commenting_on_card + before_destroy :cleanup_events def to_partial_path "cards/#{super}" end private - # FIXME: This isn't right. We need to introduce an eventable polymorphic association for this. - def cleanup_events - # 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 @@ -31,4 +25,10 @@ class Comment < ApplicationRecord def track_commenting_on_card card.track_event :commented, comment_id: id end + + # FIXME: This isn't right. We need to introduce an eventable polymorphic association for this. + def cleanup_events + # Delete events that reference directly in particulars + Event.where(particulars: { comment_id: id }).destroy_all + end end