Guest User

Untitled

a guest
Jun 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. @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')
  2. @colleges.first.count_tutorings #=> 5
Add Comment
Please, Sign In to add comment