Files
fizzy/app/models/comment.rb
T
Donal McBreen fc56ad9d7c Combine uuid-old and uuid branch changes
- Switch to binary 16 for UUID keys
- Remove AccountScopedRecord base class, all model use binary uuids now
- Fix the search sql to serialize uuids properly
- Patch the MySQL schema dumper to output binary lengths
2025-11-17 09:12:34 -05:00

28 lines
774 B
Ruby

class Comment < ApplicationRecord
include Attachments, Eventable, Mentions, Promptable, Searchable
belongs_to :account, default: -> { Current.account }
belongs_to :card, touch: true
belongs_to :creator, class_name: "User", default: -> { Current.user }
has_many :reactions, dependent: :delete_all
has_rich_text :body
scope :chronologically, -> { order created_at: :asc, id: :desc }
scope :by_system, -> { joins(:creator).where(creator: { role: "system" }) }
scope :by_user, -> { joins(:creator).where.not(creator: { role: "system" }) }
after_create_commit :watch_card_by_creator
delegate :board, :watch_by, to: :card
def to_partial_path
"cards/#{super}"
end
private
def watch_card_by_creator
card.watch_by creator
end
end