summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-30 11:23:09 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-30 11:23:09 +0100
commit544ea50a66da81989d0320735724bd09786be8ea (patch)
tree8664c7b3281cf1db31f42f359559f7d8331aba19 /app/controllers
parent6a378cc4f0bb00bdca20fda9096c833559a67f78 (diff)
Fixed some logic bugs.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/phones_controller.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb
index f1dcd3e..2698465 100644
--- a/app/controllers/phones_controller.rb
+++ b/app/controllers/phones_controller.rb
@@ -13,9 +13,9 @@ class PhonesController < ApplicationController
end
def new
- set_fallback_sip_accounts
-
@phone = @phoneable.phones.build()
+
+ set_fallback_sip_accounts
# Use the last phone.phone_model as the default.
#
@@ -80,6 +80,9 @@ class PhonesController < ApplicationController
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
+ end
end
end