diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-04 01:23:38 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-04 01:23:38 +0000 |
commit | f8bc7a4577c8c3a7abf0abc3b0b1080349ae7e20 (patch) | |
tree | 92cd1fe5a497249866019897dc60206c86bda0ca /activerecord/lib/active_record | |
parent | 5ac11f2de36e301c936cc552cffa334bf6ec2932 (diff) | |
download | rails-f8bc7a4577c8c3a7abf0abc3b0b1080349ae7e20.tar.gz rails-f8bc7a4577c8c3a7abf0abc3b0b1080349ae7e20.tar.bz2 rails-f8bc7a4577c8c3a7abf0abc3b0b1080349ae7e20.zip |
Fixed that validates_uniqueness_of used 'id' instead of defined primary key #406
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@328 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/validations.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index a451e4299a..5e9608f9db 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -213,9 +213,9 @@ module ActiveRecord for attr_name in attr_names if scope = configuration[:scope] - class_eval(%(validate %{errors.add('#{attr_name}', '#{configuration[:message]}') if self.class.find_first(new_record? ? ['#{attr_name} = ? AND #{scope} = ?', #{attr_name}, #{scope}] : ["#{attr_name} = ? AND id <> ? AND #{scope} = ?", #{attr_name}, id, #{scope}])})) + class_eval(%(validate %{errors.add('#{attr_name}', '#{configuration[:message]}') if self.class.find_first(new_record? ? ['#{attr_name} = ? AND #{scope} = ?', #{attr_name}, #{scope}] : ["#{attr_name} = ? AND \#{primary_key} <> ? AND #{scope} = ?", #{attr_name}, id, #{scope}])})) else - class_eval(%(validate %{errors.add('#{attr_name}', '#{configuration[:message]}') if self.class.find_first(new_record? ? ['#{attr_name} = ?', #{attr_name}] : ["#{attr_name} = ? AND id <> ?", #{attr_name}, id])})) + class_eval(%(validate %{errors.add('#{attr_name}', '#{configuration[:message]}') if self.class.find_first(new_record? ? ['#{attr_name} = ?', #{attr_name}] : ["#{attr_name} = ? AND \#{primary_key} <> ?", #{attr_name}, id])})) end end end |