Files
fizzy/app/models/event.rb
T
Jorge Manrubia 54f4bd5144 Generalize event's cards as eventable,add collection
Lots to tidy up but this is working
2025-04-24 12:28:16 +02:00

31 lines
703 B
Ruby

class Event < ApplicationRecord
include Notifiable, Particulars
belongs_to :collection
belongs_to :creator, class_name: "User"
belongs_to :eventable, polymorphic: true
belongs_to :summary, touch: true, class_name: "EventSummary"
scope :chronologically, -> { order created_at: :asc, id: :desc }
# TODO: Remove dependency with last_active_at via hook
after_create -> { eventable.touch(:last_active_at) }
def action
super.inquiry
end
def notifiable_target
if action.commented?
comment
else
eventable
end
end
# TODO: This doesn't belong here anymore
def initial_assignment?
action == "published" && eventable.assigned_to?(creator)
end
end