show all results on one page (gem kaminari)

2019-04-28 12:12发布

I have data and they be cut on some pages (10 results per page).

code in controller:

@messages = Message.order('id DESC').page params[:page]

How I can show all results on one page if I want? It similar as 'see all' on page navigate.

1条回答
小情绪 Triste *
2楼-- · 2019-04-28 12:43

You can put a very high limit in the per_page option if you still want the paginate helpers to work in your view.

@messages = Message.order('id DESC').page params[:page]
if params[:all]
  @messages = @messages.per_page(Message.count) # you can also hardcod' it
end
查看更多
登录 后发表回答