diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-04-28 16:55:49 -0500 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-04-28 16:55:49 -0500 |
commit | b7b319ec758ae5cd9394e87390813f7bd55e1787 (patch) | |
tree | 79947000ff35abe59171368b09c1a73d0532047d /activerecord | |
parent | 7707eb9e75587d655916645ad633cd6d45c40c03 (diff) | |
parent | be1f2db619cd2293f9d241b58884524a70d2cf16 (diff) | |
download | rails-b7b319ec758ae5cd9394e87390813f7bd55e1787.tar.gz rails-b7b319ec758ae5cd9394e87390813f7bd55e1787.tar.bz2 rails-b7b319ec758ae5cd9394e87390813f7bd55e1787.zip |
Merge pull request #14139 from anilmaurya/master
[ci skip] updating active_record/associations to demonstrate where conflict with eager loading.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 5309651725..b16983026e 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -773,6 +773,12 @@ module ActiveRecord # like this can have unintended consequences. # 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. + # + # 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. # |