Permalink
Browse files

add CollectionProxy#reload documentation

  • Loading branch information...
1 parent 1f5c1a1 commit 158a71b2cbd6be9ef9c88282b48a3e39e47908ed Francesco Rodriguez committed May 21, 2012
Showing with 18 additions and 0 deletions.
  1. +18 −0 activerecord/lib/active_record/associations/collection_proxy.rb
@@ -516,6 +516,24 @@ def clear
self
end
+ # Reloads the collection from the database. Returns +self+.
+ # Equivalent to +collection(true)+.
+ #
+ # class Person < ActiveRecord::Base
+ # has_many :pets
+ # end
+ #
+ # person.pets # fetches pets from the database
+ # # => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
+ #
+ # person.pets # uses the pets cache
+ # # => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
+ #
+ # person.pets.reload # fetches pets from the database
+ # # => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
+ #
+ # person.pets(true)  # fetches pets from the database
+ # # => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
def reload
proxy_association.reload
self

0 comments on commit 158a71b

Please sign in to comment.