From c01c28c3047bbf0be2861c7ae1146723cf4ff7a9 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sat, 1 Dec 2007 23:12:49 +0000 Subject: Warn users about the race condition in validates_uniqueness_of. [Koz] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8250 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/validations.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index bad07dd5c4..c6e6d24c91 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -595,6 +595,10 @@ module ActiveRecord # When the record is created, a check is performed to make sure that no record exists in the database with the given value for the specified # attribute (that maps to a column). When the record is updated, the same check is made but disregarding the record itself. # + # Because this check is performed outside the database there is still a chance that duplicate values + # will be inserted in two parrallel transactions. To guarantee against this you should create a + # unique index on the field. See +create_index+ for more information. + # # Configuration options: # * message - Specifies a custom error message (default is: "has already been taken") # * scope - One or more columns by which to limit the scope of the uniquness constraint. -- cgit v1.2.3