[Rails3] includes() problem with join table


I would like to create a left join between two tables, where even if an
entry in the left table has no associated entry in the right table, it
still makes its way to the end result.

But in Rails it doesn’t seem to be possible using AR instructions. So
before having to write my own query I am looking for your advice.

User <- Tracking -> Issue

Tracking is the join table, and I am only interested in knowing whether
a user has an entry in the tracking table for a given issue.

I have all the trackings for each user, but I need to only know about a
specific issue.

users.includes(:trackings).where(“trackings.issue_id = 3”)
Triggers the ugly t0_r0 request and does not honor the LEFT JOIN, i.e:
if a user has no entry in the trackings table for a given issue, then
the user is left out.

users.joins(:trackings).where(“trackings.issue_id = 3”)
Unfortunately joins() uses an INNER JOIN, so if a user has
no entry in the trackings table for a specific issue, that user is left

Any idea how to solve my problem without custom SQL?

Thanks for your support.