I would like to make a joins query but only if a condition is met.
In previous version of rails when find was used, I would be able to use:
options = { :order=> 'courses.name asc',
:include => [:units],
:group => 'courses.name',
:conditions => conditions }
options[:join] = :course_sub_responsibles if YOUR CONDITION GOES HERE
@courses = Course.find(:all, options)
But in current version, how can I do that?
See here: Rails - use join only if a condition is true
But the second answer will not work for me, because I can not build the query piece by piece. Doing so will cause the first query to fetch a huge amount of data.