aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorTaylor Mingos <taylormingos@gmail.com>2015-02-04 11:04:07 -0500
committerTaylor Mingos <taylormingos@gmail.com>2015-02-04 14:15:55 -0500
commit3c57c8608f628ec4edf3cbd82e5a87a9e02a951b (patch)
tree1115cedf3a241752b85cb3b092d6678c65ccd3a6 /guides
parentcd0ed12d1a9edc73be953d700748b5827df890c7 (diff)
downloadrails-3c57c8608f628ec4edf3cbd82e5a87a9e02a951b.tar.gz
rails-3c57c8608f628ec4edf3cbd82e5a87a9e02a951b.tar.bz2
rails-3c57c8608f628ec4edf3cbd82e5a87a9e02a951b.zip
Edit text on optional db constraints for uniqueness validations [ci skip]
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_record_validations.md5
1 files changed, 2 insertions, 3 deletions
diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md
index 67cc6a4db3..ecd1bb8ddb 100644
--- a/guides/source/active_record_validations.md
+++ b/guides/source/active_record_validations.md
@@ -606,9 +606,7 @@ This helper validates that the attribute's value is unique right before the
object gets saved. It does not create a uniqueness constraint in the database,
so it may happen that two different database connections create two records
with the same value for a column that you intend to be unique. To avoid that,
-you must create a unique index on both columns in your database. See
-[the MySQL manual](http://dev.mysql.com/doc/refman/5.6/en/multiple-column-indexes.html)
-for more details about multiple column indexes.
+you must create a unique index on that column in your database.
```ruby
class Account < ActiveRecord::Base
@@ -628,6 +626,7 @@ class Holiday < ActiveRecord::Base
message: "should happen once per year" }
end
```
+Should you wish to create a database constraint to prevent possible violations of a uniqueness validation using the `:scope` option, you must create a unique index on both columns in your database. See [the MySQL manual](http://dev.mysql.com/doc/refman/5.6/en/multiple-column-indexes.html) for more details about multiple column indexes or [the PostgreSQL manual](http://www.postgresql.org/docs/9.4/static/ddl-constraints.html) for examples of unique constraints that refer to a group of columns.
There is also a `:case_sensitive` option that you can use to define whether the
uniqueness constraint will be case sensitive or not. This option defaults to