diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-22 11:27:04 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-22 11:27:04 -0500 |
commit | e0859e569c007cd108797883eec402c876b9e8a0 (patch) | |
tree | 195a6c187d06a75c9a67daa96cdfd07718df95cf /activerecord/lib | |
parent | 21f4c2eb593f62658bbf5691c60ec3da3b0ab76d (diff) | |
download | rails-e0859e569c007cd108797883eec402c876b9e8a0.tar.gz rails-e0859e569c007cd108797883eec402c876b9e8a0.tar.bz2 rails-e0859e569c007cd108797883eec402c876b9e8a0.zip |
add more examples to CollectionProxy#find
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 6d1ba188c3..33779a9ad7 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -116,6 +116,15 @@ module ActiveRecord # # person.pets.find(1) # => #<Pet id: 1, name: "Fancy-Fancy", person_id: 1> # person.pets.find(4) # => ActiveRecord::RecordNotFound: Couldn't find Pet with id=4 + # + # person.pets.find(2) { |pet| pet.name.downcase! } + # # => #<Pet id: 2, name: "fancy-fancy", person_id: 1> + # + # person.pets.find(2, 3) + # # => [ + # # #<Pet id: 2, name: "Spook", person_id: 1>, + # # #<Pet id: 3, name: "Choo-Choo", person_id: 1> + # # ] ## # :method: first |