How do I write arbitrary SQL queries in Ruby on Rails?
December 13, 2005 1:49 PM
Subscribe
How do I write arbitrary SQL queries in Ruby on Rails?
I'm sort of learning as I go, but I can't figure this one out. All my current queries are something like MyObject.find(various conditions). That returns an array of MyObjects, and is sufficent for most purposes. But now I want to create a list of the most popular items, with a query like "select name, count(*) from MyObjects group by name order by 2". That's not going to return MyObjects, that's going to return arbitrary data columns. So how do I do that?
posted by smackfu to computers & internet (9 comments total)
posted by Kickstart70 at 2:00 PM on December 13, 2005