summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-06-04 15:06:50 +0200
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-06-04 15:06:50 +0200
commit87cf6e55f76901c340ec99cf216637a2b9672cc2 (patch)
tree8f500293a84151d177a64e3ca892eb13cd20b8f4 /app/models
parent26456e2298376ceb5bc3d7978d7c0aa146e44039 (diff)
JSON API for PagerGroup (new)
Diffstat (limited to 'app/models')
-rw-r--r--app/models/pager_group.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/pager_group.rb b/app/models/pager_group.rb
index 5c9c6ad..5c91ed8 100644
--- a/app/models/pager_group.rb
+++ b/app/models/pager_group.rb
@@ -1,5 +1,6 @@
class PagerGroup < ActiveRecord::Base
attr_accessible :sip_account_id, :callback_url
+ attr_writer :pager_group_destination_ids
has_many :pager_group_destinations, :dependent => :destroy
belongs_to :sip_account
@@ -9,6 +10,14 @@ class PagerGroup < ActiveRecord::Base
after_create :call
before_destroy :hangup_all
+ before_save :save_pager_group_destination_ids
+
+ def save_pager_group_destination_ids
+ if @pager_group_destination_ids
+ self.pager_group_destination_ids = @pager_group_destination_ids.split(/,/).map { |sip_account_id| self.pager_group_destinations.build(:sip_account_id => sip_account_id) }
+ end
+ end
+
def identifier
"pager#{self.id}"
end