Mysql sql查询rails方式不起作用

Mysql sql查询rails方式不起作用,mysql,ruby,ruby-on-rails-3,Mysql,Ruby,Ruby On Rails 3,这个查询不存在;这似乎不管用 Project.find_by_sql("select p.name as n,u.firstname,sum(i.estimated_hours) as es,(select sum(hours) as hours from time_entries where time_entries.user_id = u.id and time_entries.project_id = p.id) as spenthours from users u inner joi

这个查询不存在;这似乎不管用

Project.find_by_sql("select p.name as n,u.firstname,sum(i.estimated_hours) as es,(select sum(hours) as hours from time_entries where time_entries.user_id = u.id  and time_entries.project_id = p.id) as spenthours  from users u inner join members m on (m.user_id= :id )inner join projects p on p.id = m.project_id inner join issues i on i.assigned_to_id = u.id and i.project_id = p.id group by p.id,u.id",{:id => params[:id]})
给我像这样的错误

ActiveRecord::StatementInvalid (Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':id inner join projects p on p.id = m.project_id inner join issues i on i.assign' at line 1: 
是否有任何方法可以将参数传递到rails中的find_by_sql查询。我尝试过,但似乎不起作用。如果有任何其他合适的方法,请告诉我您需要将find_by_sql的参数包装到数组中的方法

Project.find_by_sql(["you_great_query_here", {:id => params[:id]}])
检查