Files
fizzy/app/models/bubble/commentable.rb
T
2024-10-23 17:29:24 -06:00

17 lines
361 B
Ruby

module Bubble::Commentable
extend ActiveSupport::Concern
included do
has_many :comments
scope :ordered_by_comments, -> { left_joins(:comments).group(:id).order("COUNT(comments.id) DESC") }
end
def comment!(body)
transaction do
comment = comments.create! body: body
thread_entries.create! threadable: comment
end
end
end