I am trying to execute the following sql statement in rails:
SELECT COUNT(downloads.title) AS total, downloads.title FROM `downloads` WHERE `downloads`.`member_id` = 60 Group by `downloads`.`title`
I wrote this on rails as follows:
Download.where(:member_id => id).select("COUNT(downloads.title) AS total, downloads.title").group(:title)
If I run the query directly from the SQL server, SQL will execute correctly, but if I run the activerecord version, I will only return the header.
I thought this might be due to attr_accessible, but that didn't seem to make a difference.
any ideas?
Alex
source share