1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #43286 from soartec-lab/task/fix-document-for-activerecord-uniqueness-validate

Fixed guide to `case_sensitive` option for Activerecord uniqueness validator [skip ci]
This commit is contained in:
Jonathan Hefner 2021-09-22 10:31:24 -05:00 committed by GitHub
commit 4e35354917
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 4 deletions

View file

@ -161,7 +161,7 @@ module ActiveRecord
# <tt>WHERE</tt> SQL fragment to limit the uniqueness constraint lookup
# (e.g. <tt>conditions: -> { where(status: 'active') }</tt>).
# * <tt>:case_sensitive</tt> - Looks for an exact match. Ignored by
# non-text columns (+true+ by default).
# non-text columns. The default behavior respects the default database collation.
# * <tt>:allow_nil</tt> - If set to +true+, skips this validation if the
# attribute is +nil+ (default is +false+).
# * <tt>:allow_blank</tt> - If set to +true+, skips this validation if the

View file

@ -689,9 +689,7 @@ 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](https://dev.mysql.com/doc/refman/en/multiple-column-indexes.html) for more details about multiple column indexes or [the PostgreSQL manual](https://www.postgresql.org/docs/current/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
true.
There is also a `:case_sensitive` option that you can use to define whether the uniqueness constraint will be case sensitive, case insensitive, or respects default database collation. This option defaults to respects default database collation.
```ruby
class Person < ApplicationRecord