I just created this ticket and added a patch to fix the issue + test cases. Could someone please review and apply the patch?
When the :joins option is included in a call to with_scope, the :joins in the find options are ignored. This patch updates the add_joins! method to add the :joins option from the scope and from the find options.
with_scope( :find => { :joins => "left join geocodings on users.id = geocodings.geocodable_id" } ) do find( :all, :joins => "left join taggings on users.id = taggings.taggable_id" ) end
Currently outputs:
SELECT users.* FROM users left join geocodings on users.id = geocodings.geocodable_id
With this patch, it outputs:
SELECT users.* FROM users left join taggings on users.id = taggings.taggable_id left join geocodings on users.id = geocodings.geocodable_id