From b76b13bff13cd6bcb2d543386cae9868cd4d882f Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 27 Dec 2012 14:09:53 +0100 Subject: Fallback sip account in phone views --- app/controllers/phones_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb index 0b765e8..b865cb1 100644 --- a/app/controllers/phones_controller.rb +++ b/app/controllers/phones_controller.rb @@ -13,6 +13,8 @@ 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 @phone = @phoneable.phones.build() # Use the last phone.phone_model as the default. # @@ -34,6 +36,8 @@ class PhonesController < ApplicationController end def edit + used_sip_account_ids = Phone.where('fallback_sip_account_id IS NOT NULL AND id != ?', @phone.id).collect {|r| r.fallback_sip_account_id } + @fallback_sip_accounts = SipAccount.where('sip_accountable_type = "Tenant" AND id NOT IN (?)', used_sip_account_ids).all end def update -- cgit v1.2.3