Created
August 20, 2012 18:56
-
-
Save nicolasiensen/3406690 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.joins(:pokes). | |
select("users.*, ( | |
SELECT COUNT(p.*) FROM pokes p | |
WHERE p.user_id = users.id | |
AND p.campaign_id = #{self.id} | |
) as pokes_count"). | |
where(["pokes.campaign_id = ?", self.id]).uniq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment