Forum: Ruby on Rails Embedded SQL request

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
28869a509b11eb77375d066fce22fcc8?d=identicon&s=25 Vincent Pérès (vincentp)
on 2008-11-18 17:14
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
This topic is locked and can not be replied to.