You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue appears more to be a HOW-TO issue rather than a bug in Ransack. We are in the process of cleaning up the Ransack gem and repo. If this issue is still relevant could you please ask it on StackOverflow?
If you think it is an issue with Ransack, please provide a repo with the issue and / or a pull request with failing tests. If you don't know how to do this, indicate it in the issue and we will look into it eventually.
I have a model Ticket which lists different lines for each ticket with different products, with fields TICKET, PRODUCT, QUANTITY, PRICE.
So for instance it would include lines in database like :
1, Product A, 2, 20$
1, Product B, 1, 25$
2, Product A, 1, 20$
In the example above Ticket 1 has 2 lines and Ticket 2 has 1 line.
In my view I want to show the total sales amount for each product, like:
Product A, 3, 60$
Product B, 1, 25$
Where 3 are total units sold for Product A and 60$ total sales for Product A.
If in my controller I entered:
@q = Ticket.group(:PRODUCT).sum(:PRICE, UNITS).ransack(params[:q])
@tickets = @q.result.paginate(:page => params[:page], :per_page => 30)
But I get undefined method `ransack' for #Hash:0x0056115e8456f0
If I remove sum(:PRICE, UNITS) there's no error but obviously it just groups and doesn't sum price and units.
If in controller I don't use ransack, like:
@tickets = Ticketline.group(:PRODUCT).sum(:PRICE, UNITS) no error appears and it works fine.
So my question is, is sum wrong syntax within Ransack? Or I should I sum on model instead ?
`Thanks.
The text was updated successfully, but these errors were encountered: