From f81798d06415c538f5b1c5acfd4889b45473e62d Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Fri, 25 May 2012 22:45:22 -0500 Subject: add CollectionProxy#count documentation --- .../active_record/associations/collection_proxy.rb | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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 @@ -636,9 +636,32 @@ 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 + # # => [ + # # #, + # # #, + # # # + # # ] + ## # :method: size # + # :call-seq: + # size() + # # Returns the size of the collection. If the collection hasn't been loaded, # it executes a SELECT COUNT(*) 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. -- cgit v1.2.3