Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kaminari if next page exists?

What is the method in kaminari to know if next page exists? With will_paginate its simple you just call in next_page? on model. I wonder if there is anything in kaminari

like image 662
Bhushan Lodha Avatar asked Aug 13 '14 03:08

Bhushan Lodha


People also ask

How can I paginate with kaminari?

Add page(params[:page]) in front get data query in controller function. 4. Add <%= paginate @attribute %> in html view and it is done. Kaminari automatically handles each and everything for it.

Will Paginate in rails?

will_paginate is a pagination library that integrates with Ruby on Rails, Sinatra, Hanami::View, Merb, DataMapper and Sequel. See installation instructions on the wiki for more info.


1 Answers

To check if there is a next page in the kaminari views, use current_page.next?.

To query the @posts instead you can use @posts.next_page which will return nil if there is not a next page or @posts.last_page? which will be true if there is no next page.

like image 174
infused Avatar answered Sep 28 '22 08:09

infused