aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-21 12:19:34 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-21 12:19:34 -0500
commit158a71b2cbd6be9ef9c88282b48a3e39e47908ed (patch)
tree8a8232734067b672679ebf03570e5854cc3b018e /activerecord/lib/active_record
parent1f5c1a14236b2df638d20bcf1617110c47a4bfe8 (diff)
downloadrails-158a71b2cbd6be9ef9c88282b48a3e39e47908ed.tar.gz
rails-158a71b2cbd6be9ef9c88282b48a3e39e47908ed.tar.bz2
rails-158a71b2cbd6be9ef9c88282b48a3e39e47908ed.zip
add CollectionProxy#reload documentation
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/collection_proxy.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb
index e3ebe03121..80a1715ee2 100644
--- a/activerecord/lib/active_record/associations/collection_proxy.rb
+++ b/activerecord/lib/active_record/associations/collection_proxy.rb
@@ -516,6 +516,24 @@ module ActiveRecord
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