Files
fizzy/app/models/concerns/notifiable.rb
T
2025-04-23 16:19:50 +02:00

23 lines
385 B
Ruby

module Notifiable
extend ActiveSupport::Concern
included do
has_many :notifications, as: :source, dependent: :destroy
after_create_commit :notify_recipients_later
end
def notify_recipients
Notifier.for(self)&.notify
end
def notifiable_target
self
end
private
def notify_recipients_later
NotifyRecipientsJob.perform_later self
end
end