Embedded SQL request


#1

Hello,

I’m trying to create a Rails like embedded request like that (it is
working, I’m selecting projects ordered by number of contributors) :

SELECT projects.id AS id,
project_topic,
(SELECT count(*) FROM project_users WHERE projects.id =
project_users.project_id) AS contributors
FROM projects
ORDER BY contributors DESC

I didn’t find any resource to create it in a Rails way :
Projects.find(…, :order => ‘contributors’) and do a sub-request
somewhere.

Is there anyone who could give me some links or help?

Thanks !
Vincent