Browse Source

Skip uniqueness validation when updating a setting without changing its name.

git-svn-id: http://svn.redmine.org/redmine/trunk@13720 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.0.0
Jean-Philippe Lang 9 years ago
parent
commit
3b6ba58b11
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      app/models/setting.rb

+ 1
- 1
app/models/setting.rb View 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'

Loading…
Cancel
Save