notification.rb
604 Bytes
class Notification < ActiveRecord::Base
TYPE_LIST = ["WarningNotification", "SuccessNotification", "InformationNotification",
"DangerNotification"]
attr_accessible :message, :environment_id, :active, :type
has_many :notifications_users
has_many :users, :through => :notifications_users
validates_presence_of :message
validates_presence_of :environment_id
validate :notification_type_must_be_in_type_list
def notification_type_must_be_in_type_list
unless TYPE_LIST.include?(type)
errors.add(:type, "invalid notification type")
end
end
end