diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-05-03 17:16:53 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-05-03 17:23:35 +0200 |
commit | 5757fe476a126d4f7de2791da5af0e6aeef0d1e6 (patch) | |
tree | d5a20af96475a3c9b2ec7348ef10038936d605c1 /activerecord/lib | |
parent | 022c797926591ed62d63f403ef314f2461b506ea (diff) | |
download | rails-5757fe476a126d4f7de2791da5af0e6aeef0d1e6.tar.gz rails-5757fe476a126d4f7de2791da5af0e6aeef0d1e6.tar.bz2 rails-5757fe476a126d4f7de2791da5af0e6aeef0d1e6.zip |
docs, restructure newly added part to `includes`. [ci skip]
This is a follow up to #14139.
/cc @carlosantoniodasilva
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 265bad7bc2..ac1479ad8f 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -774,16 +774,15 @@ module ActiveRecord # 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' |