The pagination works well when it's needed. But even when it's not needed -- for example, when # set for pagination is 100 and the list is less than 100 --, the pagination shows like this:
‹ Prev 1 Next ›
How can I eliminate this?
My controller:
@pagy, @users = pagy(User.all, items:100, link_extra: 'class="" style="color:#222222; margin-left:3px;"')
My view:
<%== pagy_nav(@pagy) %>
Otherwise followed the documentation
This minipost will guide you through all the required steps in order to successfully install pagy gem for pagination on a Ruby on Rails application using a custom HTML template. Start by adding the pagy gem to your application Gemfile [ appname/Gemfile] by: and perform bundle install inside directory to install the pagy gem:
If you're new to Rails, you'll be looking for a pagination gem pretty soon. Pagy is a new pagination library for Ruby on Rails. It was developed with performance in mind, without disregarding being easy to use on a new or existing Ruby on Rails application.
If you've worked with Ruby on Rails in the past, then you probably used will_paginate or Kaminari to paginate the index pages of your application. If you're new to Rails, you'll be looking for a pagination gem pretty soon. Pagy is a new pagination library for Ruby on Rails.
For that we use pagination that allow us to divide the rows on several pages and order them based on date, name or other field. On Rails applications one of the most common used gems is will_paginate.
The solution was to add this line:
<%== pagy_nav(@pagy) if @pagy.pages > 1 %>
Because unlike will_paginate or other pagination gems, pagy does not hide the link automatically.
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