Skip to content
This repository
Browse code

Merge [6790] to stable from trunk: document deep eager includes. Refe…

…rences #6267.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@6791 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 6ba8d874a9ce545f002369f464f8294cf76c989d 1 parent 75bf71d
Jeremy Kemper jeremy authored
2  activerecord/CHANGELOG
... ... @@ -1,5 +1,7 @@
1 1 *SVN*
2 2
  3 +* Document deep eager includes. #6267 [Josh Susser, Dan Manges]
  4 +
3 5 * Oracle: extract column length for CHAR also. #7866 [ymendel]
4 6
5 7 * Small additions and fixes for ActiveRecord documentation. Closes #7342 [jeremymcanally]
10 activerecord/lib/active_record/associations.rb
@@ -352,7 +352,15 @@ def clear_association_cache #:nodoc:
352 352 # for post in Post.find(:all, :include => [ :author, :comments ])
353 353 #
354 354 # That'll add another join along the lines of: LEFT OUTER JOIN comments ON comments.post_id = posts.id. And we'll be down to 1 query.
355   - # But that shouldn't fool you to think that you can pull out huge amounts of data with no performance penalty just because you've reduced
  355 + #
  356 + # To include a deep hierarchy of associations, using a hash:
  357 + #
  358 + # for post in Post.find(:all, :include => [ :author, { :comments => { :author => :gravatar } } ])
  359 + #
  360 + # That'll grab not only all the comments but all their authors and gravatar pictures. You can mix and match
  361 + # symbols, arrays and hashes in any combination to describe the associations you want to load.
  362 + #
  363 + # All of this power shouldn't fool you into thinking that you can pull out huge amounts of data with no performance penalty just because you've reduced
356 364 # the number of queries. The database still needs to send all the data to Active Record and it still needs to be processed. So it's no
357 365 # catch-all for performance problems, but it's a great way to cut down on the number of queries in a situation as the one described above.
358 366 #

0 comments on commit 6ba8d87

Please sign in to comment.
Something went wrong with that request. Please try again.