summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2012-12-31 09:32:41 +0100
committerspag <spag@golwen.net>2012-12-31 09:32:41 +0100
commite29f14a7742e7fd049a7a09a6d1fa046c2741d67 (patch)
tree303e26ef7f2892104f66b6e40f504cee436e7ade
parenta3bf87ed7d6d693c28d081c2e7e8d8e55373cae4 (diff)
fixed fallback_sip_accounts query
-rw-r--r--app/controllers/phones_controller.rb8
1 files changed, 4 insertions, 4 deletions
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