summaryrefslogtreecommitdiff
path: root/app/controllers/phones_controller.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-28 19:32:51 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-28 19:32:51 +0100
commita945a74ae1d0fbafb79c1f36f5cb3ec59970c6fe (patch)
tree6107e30015715160fa4a7e35d5fd0761631dc864 /app/controllers/phones_controller.rb
parentb2e5168b917202ebd71f3032f125691ef1fd062f (diff)
parent3b07751150c0cd70eee4e750dd7a3670120a8675 (diff)
Merge branch 'show_fallback_sip_account' into develop
Diffstat (limited to 'app/controllers/phones_controller.rb')
-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)