Skip to content

Commit

Permalink
Merge pull request rails#42625 from intrip/36027-create-or-find-by-docs
Browse files Browse the repository at this point in the history
Adjust docs of create_or_find_by
  • Loading branch information
alexcameron89 authored Jun 29, 2021
2 parents b09c110 + 562972c commit c3fe14c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions activerecord/lib/active_record/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!.
Expand All @@ -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,
Expand Down

0 comments on commit c3fe14c

Please sign in to comment.