Merge pull request #42625 from intrip/36027-create-or-find-by-docs

Adjust docs of create_or_find_by
This commit is contained in:
Alex Kitchens 2021-06-29 15:44:46 -05:00 committed by GitHub
commit c3fe14c239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -182,7 +182,7 @@ def find_or_create_by!(attributes, &block)
find_by(attributes) || create!(attributes, &block)
end
# Attempts to create a record with the given attributes in a table that has a unique constraint
# Attempts to create a record with the given attributes in a table that has a unique database constraint
# on one or several of its columns. If a row already exists with one or several of these
# unique constraints, the exception such an insertion would normally raise is caught,
# and the existing record with those attributes is found using #find_by!.
@ -193,7 +193,7 @@ def find_or_create_by!(attributes, &block)
#
# There are several drawbacks to #create_or_find_by, though:
#
# * The underlying table must have the relevant columns defined with unique constraints.
# * The underlying table must have the relevant columns defined with unique database constraints.
# * A unique constraint violation may be triggered by only one, or at least less than all,
# of the given attributes. This means that the subsequent #find_by! may fail to find a
# matching record, which will then raise an <tt>ActiveRecord::RecordNotFound</tt> exception,