From e29f14a7742e7fd049a7a09a6d1fa046c2741d67 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 31 Dec 2012 09:32:41 +0100 Subject: fixed fallback_sip_accounts query --- app/controllers/phones_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb index 2698465..14735e6 100644 --- a/app/controllers/phones_controller.rb +++ b/app/controllers/phones_controller.rb @@ -78,11 +78,11 @@ class PhonesController < ApplicationController end 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 + used_sip_account_ids = Phone.pluck(:fallback_sip_account_id) + PhoneSipAccount.pluck(:sip_account_id) + if @phone + used_sip_account_ids = used_sip_account_ids - [ @phone.fallback_sip_account_id ] end + @fallback_sip_accounts = SipAccount.where(:sip_accountable_type => 'Tenant') - SipAccount.where(:id => used_sip_account_ids) end end -- cgit v1.2.3