summaryrefslogtreecommitdiff
path: root/app/models/whitelist.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
commitb80bd744ad873f6fc43018bc4bfb90677de167bd (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /app/models/whitelist.rb
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
Start of GS5.
Diffstat (limited to 'app/models/whitelist.rb')
-rw-r--r--app/models/whitelist.rb23
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