Files
fizzy/app/models/bubble/commentable.rb
T
David Heinemeier Hansson eb0614c44f Use a more ergonomic API for watching
Passing a boolean vs using explicit on/off methods feel too low level
and doesnt read right in most of these cases.
2025-04-06 19:17:26 +02:00

21 lines
387 B
Ruby

module Bubble::Commentable
extend ActiveSupport::Concern
included do
scope :ordered_by_comments, -> { order comments_count: :desc }
end
def comment_created(comment)
increment! :comments_count
watch_by comment.creator
track_event :commented, comment_id: comment.id
rescore
end
def comment_destroyed
decrement! :comments_count
rescore
end
end