I tried
@posts = Post.page(params[:page]).per_page(10)
and
@posts = Post.paginate(:page => 1, :per_page => 10)
but neither method works
undefined method `page' for Post:Class
undefined method `paginate' for Post:Class
How do you do pagination with mongoid?
MongoDB has an extremely straightforward way to implement pagination: using skip and limit operations on a cursor. skip(n) skips n items in a query, while limit(m) returns only the next m items starting from the n-th one.
You should use Kaminari https://github.com/amatsuda/kaminari
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With