I have a very complex query which is made up of more than 1
subqueries. Arel is awesome, but it can’t generate that query. So i
generate those subqueries separately and combine them by
intersection based on some condition. Finally the generated query is
find_by_sql to get the data.
We found out that, in the jbuilder template that was rendering this
data, that it was calling association objects resulting in
Generally this problem is solved by
eager-loading in rails.
For eg. to load the company of the user, we do
Rails will do the magic(load the company of the user also in the same query) and when we refer to
view, it would not trigger any new sql query and directly access it
from ruby object.
But this doesn’t work with