From e03b0b57f4c05210d198e2fab031cb4b7bdd5247 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 11:34:36 +0100 Subject: Added destroy_fallback_sip_account_if_not_hot_deskable --- app/models/phone.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/models') diff --git a/app/models/phone.rb b/app/models/phone.rb index 1f3c497..a606834 100644 --- a/app/models/phone.rb +++ b/app/models/phone.rb @@ -20,6 +20,7 @@ class Phone < ActiveRecord::Base # Validations # before_validation :sanitize_mac_address + before_validation :destroy_fallback_sip_account_if_not_hot_deskable validates_presence_of :mac_address validate_mac_address :mac_address @@ -227,5 +228,11 @@ class Phone < ActiveRecord::Base self.last_ip_address = nil end end + + def destroy_fallback_sip_account_if_not_hot_deskable + if !self.hot_deskable? + self.fallback_sip_account_id = nil + end + end end -- cgit v1.2.3