public
Description: PLEASE CHECK http://github.com/lifo/docrails/wikis
Homepage: http://weblog.rubyonrails.org/2008/5/2/help-improve-rails-documentation-on-git-branch
Clone URL: git://github.com/lifo/docrails.git
added a class rdoc and documented count_records in has_many_association.rb
fxn (author)
Mon Aug 18 17:51:37 -0700 2008
commit  2ee60b0f70febc8c28a90e8361d9e9c2b86d4833
tree    9e6075b3d3fc3131808415d689bb6bfff04e9a6b
parent  48f56bf2beace63a20b0def4176274804e088c55
...
1
2
 
 
 
 
3
4
5
...
27
28
29
 
 
 
 
 
 
 
 
 
 
30
31
32
...
1
2
3
4
5
6
7
8
9
...
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
0
@@ -1,5 +1,9 @@
0
 module ActiveRecord
0
   module Associations
0
+    # This is the proxy that handles a has many association.
0
+    #
0
+    # If the association has a <tt>:through</tt> option further specialization
0
+    # is provided by its child HasManyThroughAssociation.
0
     class HasManyAssociation < AssociationCollection #:nodoc:
0
       # Count the number of associated records. All arguments are optional.
0
       def count(*args)
0
@@ -27,6 +31,16 @@ module ActiveRecord
0
           end
0
         end
0
 
0
+        # Returns the number of records in this collection.
0
+        #
0
+        # If the association has a counter cache it gets that value. Otherwise
0
+        # a count via SQL is performed, bounded to <tt>:limit</tt> if there's one.
0
+        # That does not depend on whether the collection has already been loaded
0
+        # or not. The +size+ method is the one that takes the loaded flag into
0
+        # account and delegates to +count_records+ if needed.
0
+        #
0
+        # If the collection is empty the target is set to an empty array and
0
+        # the loaded flag is set to true as well.
0
         def count_records
0
           count = if has_cached_counter?
0
             @owner.send(:read_attribute, cached_counter_attribute_name)

Comments

fxn Tue Aug 19 16:47:05 -0700 2008

If http://rails.lighthouseapp.com/projects/8994/tickets/865-fix-count_records#ticket-865-2 gets applied and merged back I will revise the last paragraph.