diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-25 22:45:22 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-25 22:45:22 -0500 |
commit | f81798d06415c538f5b1c5acfd4889b45473e62d (patch) | |
tree | 7d3b55a05540136d4bb17465bc12804810caad4a /activerecord/lib | |
parent | 390d86ae899f6aba735d8efa0f7f23e05c6957a5 (diff) | |
download | rails-f81798d06415c538f5b1c5acfd4889b45473e62d.tar.gz rails-f81798d06415c538f5b1c5acfd4889b45473e62d.tar.bz2 rails-f81798d06415c538f5b1c5acfd4889b45473e62d.zip |
add CollectionProxy#count documentation
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 5b5aef070d..93ed2e5a56 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -637,8 +637,31 @@ module ActiveRecord # Pet.find(4, 5, 6) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (4, 5, 6) ## + # :method: count + # + # :call-seq: + # count() + # + # Count all records using SQL. + # + # class Person < ActiveRecord::Base + # has_many :pets + # end + # + # person.pets.count # => 3 + # person.pets + # # => [ + # # #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>, + # # #<Pet id: 2, name: "Spook", person_id: 1>, + # # #<Pet id: 3, name: "Choo-Choo", person_id: 1> + # # ] + + ## # :method: size # + # :call-seq: + # size() + # # Returns the size of the collection. If the collection hasn't been loaded, # it executes a <tt>SELECT COUNT(*)</tt> query. # @@ -663,6 +686,9 @@ module ActiveRecord ## # :method: length # + # :call-seq: + # length() + # # Returns the size of the collection calling +size+ on the target. # If the collection has been already loaded, +length+ and +size+ are # equivalent. |