Skip to content

Commit aadecbe

Browse files
authored
Merge pull request rails#50541 from bparanj/document-edge-cases-for-find
Document edge cases for find
2 parents b0b1eb5 + ad9a4c2 commit aadecbe

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

activerecord/lib/active_record/relation/finder_methods.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ module FinderMethods
8787
#
8888
# Person.where(name: 'Spartacus', rating: 4).pluck(:field1, :field2)
8989
# # returns an Array of the required fields.
90+
#
91+
# ==== Edge Cases
92+
#
93+
# Person.find(37) # raises ActiveRecord::RecordNotFound exception if the record with the given ID does not exist.
94+
# Person.find([37]) # raises ActiveRecord::RecordNotFound exception if the record with the given ID in the input array does not exist.
95+
# Person.find(nil) # raises ActiveRecord::RecordNotFound exception if the argument is nil.
96+
# Person.find([]) # returns an empty array if the argument is an empty array.
97+
# Person.find # raises ActiveRecord::RecordNotFound exception if the argument is not provided.
9098
def find(*args)
9199
return super if block_given?
92100
find_with_ids(*args)

0 commit comments

Comments
 (0)