From ddb3dfa92ec0878240211cb2b7a8e125961b1360 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 5 Jan 2013 23:01:16 +0100 Subject: Moved to GsParemeter.get and set defaults for a couple of validations. --- app/models/hunt_group.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/models/hunt_group.rb') diff --git a/app/models/hunt_group.rb b/app/models/hunt_group.rb index 276ae53..184297c 100644 --- a/app/models/hunt_group.rb +++ b/app/models/hunt_group.rb @@ -8,17 +8,17 @@ class HuntGroup < ActiveRecord::Base :allow_nil => true, :allow_blank => true validates_presence_of :strategy - validates_inclusion_of :strategy, :in => HUNT_GROUP_STRATEGIES + validates_inclusion_of :strategy, :in => (GsParameter.get('HUNT_GROUP_STRATEGIES').nil? ? [] : GsParameter.get('HUNT_GROUP_STRATEGIES')) validates_presence_of :seconds_between_jumps, :if => Proc.new{ |hunt_group| hunt_group.strategy != 'ring_all' } validates_numericality_of :seconds_between_jumps, :only_integer => true, - :greater_than_or_equal_to => VALID_SECONDS_BETWEEN_JUMPS_VALUES.min, - :less_than_or_equal_to => VALID_SECONDS_BETWEEN_JUMPS_VALUES.max, + :greater_than_or_equal_to => (GsParameter.get('VALID_SECONDS_BETWEEN_JUMPS_VALUES').nil? ? 2 : GsParameter.get('VALID_SECONDS_BETWEEN_JUMPS_VALUES').min), + :less_than_or_equal_to => (GsParameter.get('VALID_SECONDS_BETWEEN_JUMPS_VALUES').nil? ? 120 : GsParameter.get('VALID_SECONDS_BETWEEN_JUMPS_VALUES').max), :if => Proc.new{ |hunt_group| hunt_group.strategy != 'ring_all' } validates_inclusion_of :seconds_between_jumps, - :in => VALID_SECONDS_BETWEEN_JUMPS_VALUES, + :in => (GsParameter.get('VALID_SECONDS_BETWEEN_JUMPS_VALUES').nil? ? [] : GsParameter.get('VALID_SECONDS_BETWEEN_JUMPS_VALUES')), :if => Proc.new{ |hunt_group| hunt_group.strategy != 'ring_all' } validates_inclusion_of :seconds_between_jumps, :in => [nil], -- cgit v1.2.3 From 49738b091eea2ca65d6f8c71b88747e314ec2950 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 10 Jan 2013 22:44:10 +0100 Subject: Refactoring and adding some caches. --- app/models/hunt_group.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/hunt_group.rb') diff --git a/app/models/hunt_group.rb b/app/models/hunt_group.rb index 184297c..5011bf0 100644 --- a/app/models/hunt_group.rb +++ b/app/models/hunt_group.rb @@ -1,7 +1,7 @@ class HuntGroup < ActiveRecord::Base attr_accessible :name, :strategy, :seconds_between_jumps, :phone_numbers_attributes - belongs_to :tenant + belongs_to :tenant, :touch => true has_many :call_forwards, :as => :call_forwardable, :dependent => :destroy validates_uniqueness_of :name, :scope => :tenant_id, -- cgit v1.2.3