diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-02-11 10:36:20 -0700 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2016-02-11 10:36:20 -0700 |
commit | 848f70e18406e3c9bd952074ce627e82a474dda7 (patch) | |
tree | 4e27ca0f92527bddb0aedd7980cfc2010166604f /activerecord/lib | |
parent | 2a56b2d90d4fed8548e3a1e7a7b206454858c872 (diff) | |
parent | f1daa2be5278bee61dfa9a6dc111b556df677ad8 (diff) | |
download | rails-848f70e18406e3c9bd952074ce627e82a474dda7.tar.gz rails-848f70e18406e3c9bd952074ce627e82a474dda7.tar.bz2 rails-848f70e18406e3c9bd952074ce627e82a474dda7.zip |
Merge pull request #23581 from diego-silva/uniqueness-validator-pk-fix
UniquenessValidator exclude itself when PK changed
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/validations/uniqueness.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index a376e2a17f..f0aa4521b5 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -19,7 +19,7 @@ module ActiveRecord relation = build_relation(finder_class, table, attribute, value) if record.persisted? && finder_class.primary_key.to_s != attribute.to_s if finder_class.primary_key - relation = relation.where.not(finder_class.primary_key => record.id) + relation = relation.where.not(finder_class.primary_key => record.id_was) else raise UnknownPrimaryKey.new(finder_class, "Can not validate uniqueness for persisted record without primary key.") end |