I have the following scope in my Order model:
scope :trial_almost_up, lambda { where :date_finished => 27.days.ago.midnight..27.days.ago.end_of_day }
Each order is tied to a User. So if you run Order.trial_almost_up and get an array of orders and run this:
o = Order.trial_almost_up
o.collect &:user
The collect runs a separate SQL statement for each Order that is tied to the user.
User Load (0.6ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 11244 LIMIT 1
User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1970 LIMIT 1
Is there anyway to combine this into one call?