[英]Pagy gem: placement of UI widget is breaking pagination
I'm using Pagy gem for pagination in my rails 5 project. 我在Rails 5项目中使用Pagy gem进行分页。 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.
分页本身可以正常工作,但是当我在视图文件中的pagination(pagy_nav(@pagy))块上方添加UI小部件(由pagy提供:pagy_items_selector(@pagy))时,它破坏了页面链接。 Example: http://www.localhost:3000/articles?page=5¤t_param=-pagy-2370055651028177601--items-
示例: http://www.localhost:3000 / articles?page = 5&current_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. 相反,如果我将pagination(pagy_nav)放在项目选择器(pagy_items_selector)上方,则该URL会整洁,并且就像一个魅力一样工作。 Example: http://www.localhost:3000/articles?page=4¤t_param=4
示例: http://www.localhost:3000 / articles?page = 4&current_param = 4
Here's my html code - 这是我的html代码-
<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>
That's a Pagy bug see #117 . 这是Pagy错误, 请参阅#117 。 It has been fixed in Pagy version 1.3.1.
它已在Pagy版本1.3.1中修复。
Updating your Gemfile should fix the problem: 更新您的Gemfile应该可以解决此问题:
bundle update pagy
If it doesn't, check the required gem in the Gemfile. 如果不是,请检查Gemfile中所需的gem。 It should be something like:
应该是这样的:
gem 'pagy', '~> 1.3` # or '1.3.1'
And update again. 并再次更新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.