Skip to content

Commit ad9a4c2

Browse files
committed
Document edge cases for ActiveRecord find method [skip ci]
1 parent d2767a0 commit ad9a4c2

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
@@ -64,6 +64,14 @@ module FinderMethods
6464
#
6565
# Person.where(name: 'Spartacus', rating: 4).pluck(:field1, :field2)
6666
# # returns an Array of the required fields.
67+
#
68+
# ==== Edge Cases
69+
#
70+
# Person.find(37) # raises ActiveRecord::RecordNotFound exception if the record with the given ID does not exist.
71+
# Person.find([37]) # raises ActiveRecord::RecordNotFound exception if the record with the given ID in the input array does not exist.
72+
# Person.find(nil) # raises ActiveRecord::RecordNotFound exception if the argument is nil.
73+
# Person.find([]) # returns an empty array if the argument is an empty array.
74+
# Person.find # raises ActiveRecord::RecordNotFound exception if the argument is not provided.
6775
def find(*args)
6876
return super if block_given?
6977
find_with_ids(*args)

0 commit comments

Comments
 (0)