diff options
Diffstat (limited to 'app/models/whitelist.rb')
-rw-r--r-- | app/models/whitelist.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/models/whitelist.rb b/app/models/whitelist.rb new file mode 100644 index 0000000..8303728 --- /dev/null +++ b/app/models/whitelist.rb @@ -0,0 +1,23 @@ +class Whitelist < ActiveRecord::Base + attr_accessible :name, :phone_numbers_attributes, :uuid + + belongs_to :whitelistable, :polymorphic => true + + # These are the phone_numbers for this whitelist. + # + has_many :phone_numbers, :as => :phone_numberable, :dependent => :destroy + + accepts_nested_attributes_for :phone_numbers, + :reject_if => lambda { |phone_number| phone_number[:number].blank? }, + :allow_destroy => true + + acts_as_list :scope => [ :whitelistable_type, :whitelistable_id ] + + validates_presence_of :uuid + validates_uniqueness_of :uuid + + def to_s + self.name || I18n.t('whitelists.name') + ' ID ' + self.id.to_s + end + +end |