简体   繁体   中英

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. 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?

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

要么

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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