diff options
author | anilmaurya <anilmaurya8dec@gmail.com> | 2014-02-21 17:39:07 +0530 |
---|---|---|
committer | anilmaurya <anilmaurya8dec@gmail.com> | 2014-04-29 01:44:24 +0530 |
commit | be1f2db619cd2293f9d241b58884524a70d2cf16 (patch) | |
tree | dc94f2c0ae4d057e3f399d7c224e2f4f8cd5f1f7 /activerecord/lib | |
parent | c93c558aa81721653dd18cdc45f3f7299dfa8a72 (diff) | |
download | rails-be1f2db619cd2293f9d241b58884524a70d2cf16.tar.gz rails-be1f2db619cd2293f9d241b58884524a70d2cf16.tar.bz2 rails-be1f2db619cd2293f9d241b58884524a70d2cf16.zip |
[ci skip] updating active_record/associations to demonstrate where conflict with eager loading.
Diffstat (limited to 'activerecord/lib')
-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 142d21ce92..05dd1d47c4 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -767,6 +767,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. # |