From 87cf6e55f76901c340ec99cf216637a2b9672cc2 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 4 Jun 2013 15:06:50 +0200 Subject: JSON API for PagerGroup (new) --- app/models/pager_group.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/models') 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 -- cgit v1.2.3