From 544ea50a66da81989d0320735724bd09786be8ea Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 11:23:09 +0100 Subject: Fixed some logic bugs. --- app/controllers/phones_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app/controllers/phones_controller.rb') diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb index f1dcd3e..2698465 100644 --- a/app/controllers/phones_controller.rb +++ b/app/controllers/phones_controller.rb @@ -13,9 +13,9 @@ class PhonesController < ApplicationController end def new - set_fallback_sip_accounts - @phone = @phoneable.phones.build() + + set_fallback_sip_accounts # Use the last phone.phone_model as the default. # @@ -80,6 +80,9 @@ class PhonesController < ApplicationController def set_fallback_sip_accounts used_sip_account_ids = Phone.where(:fallback_sip_account_id => SipAccount.pluck(:id)).pluck(:fallback_sip_account_id) @fallback_sip_accounts = SipAccount.where(:sip_accountable_type => 'Tenant').where(:hotdeskable => true) - SipAccount.where(:id => used_sip_account_ids) + if @phone && !@phone.fallback_sip_account_id.blank? && SipAccount.exists?(@phone.fallback_sip_account_id) + @fallback_sip_accounts << SipAccount.where(:id => @phone.fallback_sip_account_id).first + end end end -- cgit v1.2.3