app/models/notification.rb
class Notification < ActiveRecord::Base
belongs_to :recipient, class_name: 'User'
belongs_to :actor, class_name: 'User'
belongs_to :notifiable, polymorphic: true
scope :unread, -> { where(read_at: nil) }
scope :logged_in, ->(user) { where(recipient: user) }
end