Embedded SQL request


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,
(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

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

Thanks !

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs