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
Made more clear the case of ignored :limit option for eager loaded associations
jodosha (author)
Sun Nov 02 01:36:38 -0800 2008
commit  27ec3ee00975a6655d2949520a6545e831751024
tree    0f9634bd1b2ed024522f57e32bbb91fcd8b95017
parent  1147453fce0890ea229c3af5f43c909ebe53061e
...
507
508
509
 
 
 
 
 
 
 
 
510
511
512
...
507
508
509
510
511
512
513
514
515
516
517
518
519
520
0
@@ -507,6 +507,14 @@ module ActiveRecord
0
     #
0
     # will load posts and eager load the +approved_comments+ association, which contains only those comments that have been approved.
0
     #
0
+    # If you eager load an association with a specified <tt>:limit</tt> option, it will be ignored, returning all the associated objects:
0
+    #
0
+    #   class Picture < ActiveRecord::Base
0
+    #     has_many :most_recent_comments, :class_name => 'Comment', :order => 'id DESC', :limit => 10
0
+    #   end
0
+    #
0
+    #   Picture.find(:first, :include => :most_recent_comments).most_recent_comments # => returns all associated comments.
0
+    #
0
     # When eager loaded, conditions are interpolated in the context of the model class, not the model instance.  Conditions are lazily interpolated
0
     # before the actual model exists.
0
     #

Comments