Permalink
Browse files

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
  • Loading branch information...
NZKoz committed Dec 1, 2007
1 parent 2a3dc59 commit c01c28c3047bbf0be2861c7ae1146723cf4ff7a9
Showing with 4 additions and 0 deletions.
  1. +4 −0 activerecord/lib/active_record/validations.rb
@@ -595,6 +595,10 @@ def validates_length_of(*attrs)
# 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:
# * <tt>message</tt> - Specifies a custom error message (default is: "has already been taken")
# * <tt>scope</tt> - One or more columns by which to limit the scope of the uniquness constraint.

0 comments on commit c01c28c

Please sign in to comment.