diff options
author | Xavier Noria <fxn@hashref.com> | 2012-04-12 19:58:08 -0700 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2012-04-12 19:58:08 -0700 |
commit | 4e3e5138b537e999b5bdf6fbb1243890123ada5d (patch) | |
tree | 9c4d0291390a12202d22c772e243326f100cb9eb /activerecord | |
parent | 8c2c60511beaad05a218e73c4918ab89fb1804f0 (diff) | |
parent | dcb2279674fef7358c894445c9cd7c4827b90b10 (diff) | |
download | rails-4e3e5138b537e999b5bdf6fbb1243890123ada5d.tar.gz rails-4e3e5138b537e999b5bdf6fbb1243890123ada5d.tar.bz2 rails-4e3e5138b537e999b5bdf6fbb1243890123ada5d.zip |
Merge pull request #5830 from raganwald/master
Update RDoc to mention integer coercion in ActiveRecord’s find by id
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 74f8e30404..52061a2286 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -6,7 +6,8 @@ module ActiveRecord # 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]). - # 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 # 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>. @@ -51,6 +52,7 @@ module ActiveRecord # # # find by id # 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([7, 17]) # returns an array for objects with IDs in (7, 17) # Person.find([1]) # returns an array for the object with ID = 1 |