Reputation: 3
I'm using Pagy gem for pagination in my rails 5 project. Pagination itself works fine, but when I add a UI widget (provided by pagy: pagy_items_selector(@pagy)) above pagination(pagy_nav(@pagy)) chunk in my view file, it's breaking the page links. Example: http://www.localhost:3000/articles?page=5¤t_param=-pagy-2370055651028177601--items-
Instead if I place pagination(pagy_nav) above items selector (pagy_items_selector), the url is neat and works like a charm. Example: http://www.localhost:3000/articles?page=4¤t_param=4
Here's my html code -
<div class="items_per_page">
<!-- Pagy UI widget for users to select items per page -->
<%= pagy_items_selector(@pagy).html_safe %>
</div>
<!-- displaying a list of article titles -->
<% @articles.each do |article| %>
<div class="row justify-content-md-center newsbox">
<div class="article-content">
<div class=" panel-title">
<%= link_to article.title, article_path(article) %>
</div>
</div>
</div>
<% end %>
<!--Pagy Nav links -->
<div class="pager">
<!-- Pagination nav links -->
<%= pagy_nav(@pagy).html_safe %>
</div>
Upvotes: 0
Views: 445
Reputation: 11
That's a Pagy bug see #117. It has been fixed in Pagy version 1.3.1.
Updating your Gemfile should fix the problem:
bundle update pagy
If it doesn't, check the required gem in the Gemfile. It should be something like:
gem 'pagy', '~> 1.3` # or '1.3.1'
And update again.
Upvotes: 1