Skip to content

Commit 562972c

Browse files
intripeileencodes
andcommitted
Adjust docs of create_or_find_by
- Mention explicitly in the docs that `create_of_find_by` requires a DB constraint. Closes rails#36027 Co-authored-by: Eileen M. Uchitelle <[email protected]>
1 parent 1cdee90 commit 562972c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

activerecord/lib/active_record/relation.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def find_or_create_by!(attributes, &block)
182182
find_by(attributes) || create!(attributes, &block)
183183
end
184184

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

0 commit comments

Comments
 (0)