]> source.dussan.org Git - redmine.git/commitdiff
Skip uniqueness validation when updating a setting without changing its name.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 5 Dec 2014 15:02:29 +0000 (15:02 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 5 Dec 2014 15:02:29 +0000 (15:02 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13720 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/setting.rb

index bc02d29cea63107545b06a848189aef65c69b42d..a16eede4ed441a44130f4b7a4cfef68f79a56f16 100644 (file)
@@ -77,7 +77,7 @@ class Setting < ActiveRecord::Base
   cattr_accessor :available_settings
   self.available_settings ||= {}
 
-  validates_uniqueness_of :name
+  validates_uniqueness_of :name, :if => Proc.new {|setting| setting.new_record? || setting.name_changed?}
   validates_inclusion_of :name, :in => Proc.new {available_settings.keys}
   validates_numericality_of :value, :only_integer => true, :if => Proc.new { |setting|
     (s = available_settings[setting.name]) && s['format'] == 'int'