Skip to content
This repository
Browse code

add more examples to CollectionProxy#find

  • Loading branch information...
commit e0859e569c007cd108797883eec402c876b9e8a0 1 parent 21f4c2e
Francesco Rodríguez authored May 22, 2012
9  activerecord/lib/active_record/associations/collection_proxy.rb
@@ -116,6 +116,15 @@ class CollectionProxy < Relation
116 116
       #   
117 117
       #   person.pets.find(1) # => #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>
118 118
       #   person.pets.find(4) # => ActiveRecord::RecordNotFound: Couldn't find Pet with id=4
  119
+      #
  120
+      #   person.pets.find(2) { |pet| pet.name.downcase! }
  121
+      #   # => #<Pet id: 2, name: "fancy-fancy", person_id: 1>
  122
+      #
  123
+      #   person.pets.find(2, 3)
  124
+      #   # => [
  125
+      #   #       #<Pet id: 2, name: "Spook", person_id: 1>,
  126
+      #   #       #<Pet id: 3, name: "Choo-Choo", person_id: 1>
  127
+      #   #    ]
119 128
 
120 129
       ##
121 130
       # :method: first

0 notes on commit e0859e5

Please sign in to comment.
Something went wrong with that request. Please try again.