简体   繁体   English

[2,7,0,0]的未定义方法`group':Array [Chartkick]

[英]Undefined method `group' for [2, 7, 0, 0]:Array [Chartkick]

I am trying to create a chart for a Pack database, in which the x axis will be each day, and the y axis will be a count of the :amount field in the Pack database. 我正在尝试为Pack数据库创建一个图表,其中x轴为每天,而y轴为Pack数据库中:amount字段的计数。 I am currently using the following code: 我目前正在使用以下代码:

= line_chart @packs.pluck("amount").group(:created_at).count

I am getting this error: 我收到此错误:

undefined method `group' for [2, 7, 0, 0]:Array

How do I display a chart using Chartkick, in which it counts or shows the :amount record for that day? 如何使用Chartkick显示图表,在该图表中计数或显示当天的:amount记录?

= line_chart @packs.group(:created_at).count('amount')

要么

= line_chart @packs.group(:created_at).sum('amount')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM