Skip to content

Commit

Permalink
Merge pull request #5830 from raganwald/master
Browse files Browse the repository at this point in the history
Update RDoc to mention integer coercion in ActiveRecord’s find by id
  • Loading branch information
fxn committed Apr 13, 2012
2 parents 8c2c605 + dcb2279 commit 4e3e513
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion activerecord/lib/active_record/relation/finder_methods.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module FinderMethods
# Find operates with four different retrieval approaches: # Find operates with four different retrieval approaches:
# #
# * Find by id - This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]). # * Find by id - This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]).
# If no record can be found for all of the listed ids, then RecordNotFound will be raised. # If no record can be found for all of the listed ids, then RecordNotFound will be raised. If the primary key
# is an integer, find by id coerces its arguments using +to_i+.
# * Find first - This will return the first record matched by the options used. These options can either be specific # * Find first - This will return the first record matched by the options used. These options can either be specific
# conditions or merely an order. If no record can be matched, +nil+ is returned. Use # conditions or merely an order. If no record can be matched, +nil+ is returned. Use
# <tt>Model.find(:first, *args)</tt> or its shortcut <tt>Model.first(*args)</tt>. # <tt>Model.find(:first, *args)</tt> or its shortcut <tt>Model.first(*args)</tt>.
Expand Down Expand Up @@ -51,6 +52,7 @@ module FinderMethods
# #
# # find by id # # find by id
# Person.find(1) # returns the object for ID = 1 # Person.find(1) # returns the object for ID = 1
# Person.find("1") # returns the object for ID = 1
# Person.find(1, 2, 6) # returns an array for objects with IDs in (1, 2, 6) # Person.find(1, 2, 6) # returns an array for objects with IDs in (1, 2, 6)
# Person.find([7, 17]) # returns an array for objects with IDs in (7, 17) # Person.find([7, 17]) # returns an array for objects with IDs in (7, 17)
# Person.find([1]) # returns an array for the object with ID = 1 # Person.find([1]) # returns an array for the object with ID = 1
Expand Down

0 comments on commit 4e3e513

Please sign in to comment.