← Back to Upcase

Querying with Custom Joins

(Upcase ) #1
This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/advanced-querying-custom-joins.

(Bernardo Farah) #5

Question: Would #eager_load() work here? Or is there differing behavior that would make that a bad idea? My understanding is that eager_load uses LEFT OUTER JOIN.

…and as I keep watching the video my question is answered :grinning:

(Amanda Dolan) #6

This is just a reminder that Rails 5, adds a left_outer_joins method.

Rails 5 also adds an or method which allows you to join clauses with OR, but I can’t find documentation, only this SO thread (and the pull request).

Obviously these still good demonstrations of how to write the minimum SQL that you need, just wanted to point out that for these common situations, there are now methods available.

(Bruno Miranda) #7

in Docs now http://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html :smile: