From 4e67f8769a3a3199bfb5b363fe9baa231c329a2b Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 20 Jan 2013 20:57:35 +0100 Subject: Refactoring --- app/models/gateway.rb | 7 +++++++ app/models/tenant.rb | 11 ++--------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'app/models') diff --git a/app/models/gateway.rb b/app/models/gateway.rb index 21dc831..3e791a6 100644 --- a/app/models/gateway.rb +++ b/app/models/gateway.rb @@ -14,6 +14,7 @@ class Gateway < ActiveRecord::Base :presence => true, :inclusion => { :in => TECHNOLOGIES } + after_initialize :set_defaults before_validation :downcase_technology def to_s @@ -25,4 +26,10 @@ class Gateway < ActiveRecord::Base self.technology = self.technology.downcase if !self.technology.blank? end + def set_defaults + if TECHNOLOGIES.count == 1 + self.technology = TECHNOLOGIES.first + end + end + end diff --git a/app/models/tenant.rb b/app/models/tenant.rb index c3e2926..419ac3a 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -1,15 +1,8 @@ # encoding: UTF-8 class Tenant < ActiveRecord::Base - attr_accessible :name, :description, :sip_domain_id, :country_id, :language_id, :from_field_pin_change_email, :from_field_voicemail_email - - if GsParameter.get('STRICT_INTERNAL_EXTENSION_HANDLING') == true - attr_accessible :internal_extension_ranges - end - - if GsParameter.get('STRICT_DID_HANDLING') == true - attr_accessible :did_list - end + # https://github.com/rails/strong_parameters + include ActiveModel::ForbiddenAttributesProtection # Associations: # -- cgit v1.2.3