show all results on one page (gem kaminari)

陌路散爱 提交于 2019-12-07 02:57:46

问题


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:


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


来源:https://stackoverflow.com/questions/11818158/show-all-results-on-one-page-gem-kaminari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!