我有个小问题,通过Activerecord Query Interface写的其实是:
Gp.select("date('gps'.'created_at') as date,('users'.'name') as name, SUM('gps'.'sum_issue') as sum_issue").joins('LEFT JOIN users ON users.id = gps.user_id').where("users.ab_id = :abs_id AND users.id != 20", {:abs_id => current_user.ab_id}).group("users.name")
查询结果必须是用户名、总和、日期。如果我直接从 SQLlite 执行此查询,则可以,但是 Active Record 查询接口给了我
[#<Gp sum_issue: 289000>, #<Gp sum_issue: 364130>, #<Gp sum_issue: 620000>]
我如何获得名称、日期、sum_issue 并将其显示在我的助手中。像这样:
{
created_at: datet,
sum_issue: sum_issue,
name: name
}