Ruby on rails Rails:Chartkick gem-总结收入

Ruby on rails Rails:Chartkick gem-总结收入,ruby-on-rails,Ruby On Rails,我用的是沙特基克宝石。截取的代码应实际显示特定用户的收入: <%= area_chart Order.where(:user_name => current_user.name).group_by_day(:created_at).maximum(:totalprice), library: {isStacked: false, vAxis: {title: "Revenue"}, hAxis: {title: 'Date'}} %> current\u user.name)

我用的是沙特基克宝石。截取的代码应实际显示特定用户的收入:

<%= area_chart Order.where(:user_name => current_user.name).group_by_day(:created_at).maximum(:totalprice), library: {isStacked: false, vAxis: {title: "Revenue"}, hAxis: {title: 'Date'}} %>
current\u user.name).按天分组(:created\u at).最大值(:totalprice),库:{isStacked:false,vAxis:{title:Revenue},hAxis:{title:'Date'}}%>
但它只显示最后一个
totalprice
。例如,如果某一天有2件物品出售(例如价值300+600美元),则只显示600美元标记。如何转换上面的代码,使其汇总所有
Order.totalprice
条目


提前谢谢

Maximum获得最高的总价,如果要将它们相加,则需要求和

<%= area_chart Order.where(:user_name => current_user.name).group_by_day(:created_at).sum(:totalprice), library: {isStacked: false, vAxis: {title: "Revenue"}, hAxis: {title: 'Date'}} %>
current\u user.name).按天分组(:created\u at).sum(:totalprice),库:{isStacked:false,vAxis:{title:Revenue},hAxis:{title:'Date'}}%>

尝试删除
最大值
无效<代码>最大值应该存在,因为这不起作用<代码>PG::UnfinedFunction:错误:函数sum(字符变化)不存在第1行:选择sum(“订单”,“总价”)作为sum\u totalprice,(日期…在
totalprice
列上的类型是什么?
T.string“totalprice”
我需要它作为字符串,因为我在处理“,”以及“.”作为分隔符。它必须是
smallint、int、bigint、real、double-precision、numeric、interval或money
类型。切换到该类型是因为将价格存储为字符串没有意义,您可以使用
number\u to\u currency
帮助器在视图中格式化它。为什么不可以?您可以使用从数字到货币。