app/models/wupee/notification.rb in wupee-1.1.4 vs app/models/wupee/notification.rb in wupee-2.0.0.beta1
- old
+ new
@@ -1,13 +1,16 @@
class Wupee::Notification < ActiveRecord::Base
belongs_to :receiver, polymorphic: true
belongs_to :attached_object, polymorphic: true
belongs_to :notification_type, class_name: "Wupee::NotificationType"
- validates_presence_of :receiver,
- :notification_type
+ validates :receiver, presence: true
+ validates :notification_type, presence: true
+ scope :read, -> { where(is_read: true) }
scope :unread, -> { where(is_read: false) }
+ scope :wanted, -> { where(is_wanted: true) }
+ scope :unwanted, -> { where(is_wanted: false) }
scope :ordered, -> { order(created_at: :desc) }
def mark_as_read
update_columns(is_read: true)
end