scinote-web/app/models/notification.rb

14 lines
419 B
Ruby
Raw Normal View History

class Notification < ActiveRecord::Base
has_many :user_notifications, inverse_of: :notification
has_many :users, through: :user_notifications
2016-09-29 20:49:58 +08:00
belongs_to :generator_user, class_name: 'User'
enum type_of: [:assignment, :recent_changes, :system_message]
2016-10-03 14:20:23 +08:00
def already_seen(user)
UserNotification.where(notification: self, user: user)
.pluck(:checked)
.first
end
end