Fixed that validating a Setting with invalid name triggers an error (#15551).

git-svn-id: http://svn.redmine.org/redmine/trunk@12348 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2013-11-29 21:18:35 +00:00
parent 088ab2e686
commit 23974fb0ce
2 changed files with 17 additions and 1 deletions

View File

@@ -83,7 +83,9 @@ class Setting < ActiveRecord::Base
validates_uniqueness_of :name
validates_inclusion_of :name, :in => @@available_settings.keys
validates_numericality_of :value, :only_integer => true, :if => Proc.new { |setting| @@available_settings[setting.name]['format'] == 'int' }
validates_numericality_of :value, :only_integer => true, :if => Proc.new { |setting|
(s = @@available_settings[setting.name]) && s['format'] == 'int'
}
# Hash used to cache setting values
@cached_settings = {}