show all results on one page (gem kaminari)
Asked Answered
A

1

7

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.

Aluin answered 5/8, 2012 at 16:39 Comment(0)
L
12

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
Lunn answered 5/8, 2012 at 17:9 Comment(1)
Just fyi, for more recent versions, instead of .per_page it is .perBraille

© 2022 - 2024 — McMap. All rights reserved.