开发者

Rails3 Kaminari undefined with .all

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(开发者_StackOverflow['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>


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜