Files
fizzy/app/models/notification.rb
T
Kevin McConnell df1225e58d Style
2025-01-13 14:21:47 +00:00

11 lines
351 B
Ruby

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