Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @colleges = College.find(:all, :select => "*, SUM(IF(c.college_id = colleges.id), 1, 0) AS count_tutorings", :joins => { :users => [:colleges, :tutorings] }, :group => 'c.college_id')
- @colleges.first.count_tutorings #=> 5
Add Comment
Please, Sign In to add comment