Hey,
I have a problem very similar to the one exposed here in RubyOnRails Guide.
This query :
Client.all :joins => :orders,
:conditions => { :orders => {:created_at => time_range}}
should return all the clients with their orders if they made some orders within the time range. Am I right?
What I want is slightly different : I want all the client wether they made an order or not in the time range. If they made some orders, I want them though. I came up with that :
Client.all :joins => 'LEFT OUTER JOIN orders ON orders.client_id = clients.id',
:conditions => {:orders => {:created_at => time_range}})
But this doesn't give me the clients who didn't make an order... Can someone help with that?