From 3b07751150c0cd70eee4e750dd7a3670120a8675 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 28 Dec 2012 19:31:31 +0100 Subject: Fallback SIP Accounts are only shown when the hotdeskable field is checked. --- app/controllers/phones_controller.rb | 6 ++++-- 1 file changed, 4 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 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) -- cgit v1.2.3