Skip to content
Browse files

docs, restructure newly added part to `includes`. [ci skip]

This is a follow up to #14139.

/cc @carlosantoniodasilva
  • Loading branch information...
1 parent 022c797 commit 5757fe476a126d4f7de2791da5af0e6aeef0d1e6 @senny senny committed May 3, 2014
Showing with 5 additions and 6 deletions.
  1. +5 −6 activerecord/lib/active_record/associations.rb
View
11 activerecord/lib/active_record/associations.rb
@@ -774,16 +774,15 @@ def association_instance_set(name, association)
# In the above example posts with no approved comments are not returned at all, because
# the conditions apply to the SQL statement as a whole and not just to the association.
#
+ # You must disambiguate column references for this fallback to happen, for example
+ # <tt>order: "author.name DESC"</tt> will work but <tt>order: "name DESC"</tt> will not.
+ #
# If you want to load all posts (including posts with no approved comments) then write
# your own LEFT OUTER JOIN query using ON
#
- # Post.joins('LEFT OUTER JOIN comments ON comments.post_id = posts.id AND comments.approved = true')
- #
- # You must disambiguate column references for this fallback to happen, for example
- # <tt>order: "author.name DESC"</tt> will work but <tt>order: "name DESC"</tt> will not.
+ # Post.joins("LEFT OUTER JOIN comments ON comments.post_id = posts.id AND comments.approved = '1'")
#
- # If you do want eager load only some members of an association it is usually more natural
- # to include an association which has conditions defined on it:
+ # In this case it is usually more natural to include an association which has conditions defined on it:
#
# class Post < ActiveRecord::Base
# has_many :approved_comments, -> { where approved: true }, class_name: 'Comment'

0 comments on commit 5757fe4

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