Files
fizzy/app/models/event.rb
T
Jorge Manrubia 043230394e Tidy up event helper code
Also, revert to using a helper method to determine the event action, since this is purely a view concern. Keep method at the event model to identify initial assignments.
2025-04-23 13:35:09 +02:00

23 lines
565 B
Ruby

class Event < ApplicationRecord
include Notifiable, Particulars
belongs_to :creator, class_name: "User"
belongs_to :summary, touch: true, class_name: "EventSummary"
belongs_to :card
has_one :message, through: :summary
has_one :comment, through: :message, source: :messageable, source_type: "Comment"
scope :chronologically, -> { order created_at: :asc, id: :desc }
after_create -> { card.touch(:last_active_at) }
def action
super&.inquiry
end
def initial_assignment?
action == "published" && card.assigned_to?(creator)
end
end