Reputation: 7166
Hi I wonder how to work around the problem I have with the pagination gem "Kaminari".
For what I've understood you cant paginate @user = User.all.page(5)?
But what if I have this code and want to paginate that, is it possible or do I need to change the code?
@price = Price.joins(:retailer, :retailer => :profile).
where(['product_id=? AND size_id=?', params[:prod_id], params[:si_id]]).
group(:retailer_id).order("SUM((prices.price * #{params[:amount].to_i}) + profiles.shippingCost)").all
The only thing I receive right now when applying.page(5) to that code is
undefined method `page' for #<Class:0x000001023c4558>
Upvotes: 1
Views: 1127
Reputation: 20645
You don't need the .all
because the joins call, along with where and group, is returning an array of objects for you that meet your criteria. Remove your .all and call page on the instance variable (which you might want to rename to @pages
or something else plural).
Upvotes: 1