From 0442cd19bc9383669b506185356227361a16e442 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 09:29:40 -0500 Subject: call_forwards - polymorphism added --- app/models/sip_account.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/models/sip_account.rb') diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index 420e395..a39982b 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -16,7 +16,7 @@ class SipAccount < ActiveRecord::Base has_many :phones, :through => :phone_sip_accounts has_many :phone_numbers, :as => :phone_numberable, :dependent => :destroy - has_many :call_forwards, :through => :phone_numbers + has_many :call_forwards, :as => :call_forwardable, :dependent => :destroy belongs_to :tenant belongs_to :sip_domain @@ -96,8 +96,8 @@ class SipAccount < ActiveRecord::Base if call_forwarding_master.active call_forwarding_master.active = false else - if call_forwarding_service = 'assistant' && call_forwarding_master.call_forwardable_type == 'HuntGroup' && call_forwarding_master.call_forwardable - if call_forwarding_master.call_forwardable.hunt_group_members.where(:active => true).count > 0 + if call_forwarding_service = 'assistant' && call_forwarding_master.destinationable_type == 'HuntGroup' && call_forwarding_master.destinationable + if call_forwarding_master.destinationable.hunt_group_members.where(:active => true).count > 0 call_forwarding_master.active = true else call_forwarding_master.active = false @@ -109,7 +109,7 @@ class SipAccount < ActiveRecord::Base call_forwarding = phone_number.call_forwards.where(:call_forward_case_id => service_id).order(:active).all(:conditions => 'source IS NULL OR source = ""').first if ! call_forwarding call_forwarding = CallForward.new() - call_forwarding.phone_number_id = phone_number.id + call_forwarding.call_forwardable = phone_number end if to_voicemail == nil -- cgit v1.2.3