eager loading has_many through

The problem is that I only get the users with a statistics record and I also want users without any stastics. I think the problem is caused by :conditions => ["statistics.event_id = ?", event.id] but I don't know how to include the event_id in another way.

Someone can help me out?

Thanks -Stijn

Try using the :joins parameter and manually join to the statistics table with an OUTER join, or use the find_by_sql method if you have to.

The joins param value will be something like :joins => "left outer join statistics s on s.user_id = user.id"

Having the left outer join should still allow you to filter the the statistics with the event_id and include the users with and without stats.