doc: Warn against having uniqueness validator when create_or_find_by is used
Co-authored-by: Petrik de Heus <petrik@deheus.net>
This commit is contained in:
parent
9940dc879d
commit
a42eda12da
@ -255,6 +255,8 @@ def find_or_create_by!(attributes, &block)
|
||||
# the problem of running out of integers, if the underlying table is still stuck on a primary
|
||||
# key of type int (note: All \Rails apps since 5.1+ have defaulted to bigint, which is not liable
|
||||
# to this problem).
|
||||
# * Columns with unique database constraints should not have uniqueness validations defined,
|
||||
# otherwise #create will fail due to validation errors and #find_by will never be called.
|
||||
#
|
||||
# This method will return a record if all given attributes are covered by unique constraints
|
||||
# (unless the INSERT -> DELETE -> SELECT race condition is triggered), but if creation was attempted
|
||||
|
Loading…
Reference in New Issue
Block a user