wrong `number of arguments (given 4, expected 2..3)` error, when pulling data from model to display in a chart

351 Views Asked by At

In an ROR app I'm working on I'm getting this error wrong number of arguments (given 4, expected 2..3) when using this line of code:

 <%= column_chart current_user.papers.group(:paper_type).group_by_month(:date, format: "%b, %y").sum("paper_weight * #{ @OtherTypes}", "paper_weight * #{ @NewspaperCo2}", "paper_weight * #{ @Officepaperco2}") %> 

The problem is that I'm not sure how to display all Paper types and multiply its weight with separate variable for each paper type.

I'm using chartkick to display the column chart.

There are four paper types, Officepaper, Newspaper, Magazines and Others each paper type has it´s own variable that have to be multiplied with the paper type weight and the outcome is shown on a column chart.

But if I take out one Item from the code it works, like this:

 <%= column_chart current_user.papers.group(:paper_type).group_by_month(:date, format: "%b, %y").sum("paper_weight * #{ @OtherTypes}", "paper_weight * #{ @NewspaperCo2}") %> 

And the app displays this chart as it is supposed to do: enter image description here
Can someone please explain to me why I'm getting this error and what to do about it.

Thank you

0

There are 0 best solutions below