summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-28 19:31:31 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-28 19:31:31 +0100
commit3b07751150c0cd70eee4e750dd7a3670120a8675 (patch)
tree6107e30015715160fa4a7e35d5fd0761631dc864 /app/controllers
parentb2e5168b917202ebd71f3032f125691ef1fd062f (diff)
Fallback SIP Accounts are only shown when the hotdeskable field is checked.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/phones_controller.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb
index b865cb1..b23a589 100644
--- a/app/controllers/phones_controller.rb
+++ b/app/controllers/phones_controller.rb
@@ -13,9 +13,11 @@ class PhonesController < ApplicationController
end
def new
- used_sip_account_ids = Phone.where('fallback_sip_account_id IS NOT NULL').collect {|r| r.fallback_sip_account }
- @fallback_sip_accounts = SipAccount.where('sip_accountable_type = "Tenant" AND id NOT IN (?)', used_sip_account_ids).all
+ 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)
+
@phone = @phoneable.phones.build()
+
# Use the last phone.phone_model as the default.
#
@phone.phone_model_id = Phone.last.try(:phone_model).try(:id)