Files
fizzy/app/models/notification.rb
T
2025-01-14 13:08:12 +00:00

14 lines
383 B
Ruby

class Notification < ApplicationRecord
belongs_to :user
belongs_to :event
belongs_to :bubble
belongs_to :resource, polymorphic: true
scope :unread, -> { where(read: false) }
scope :ordered, -> { order(read: :desc, created_at: :desc) }
delegate :creator, to: :event
broadcasts_to ->(notification) { [ notification.user, :notifications ] }, inserts_by: :prepend
end