分页:如何从“params[:page]”获取(从)到(到)
我想添加他们的分页器以具有如下内容:
450 中的 1–30
我能够从命名范围中获取总数。我很好奇是否有办法获取另外两个而不是用 params[:page]
值来处理?
I'd like to add their paginator to have something like the following:
1–30 of 450
I'm able to get the total from a named scope. I'm curious if there is a way to get the other two rather than mucking with the params[:page]
value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个名为
page_entries_info 它提供了您需要的信息:
请注意,它不是很可定制,但您也许可以基于它编写自己的简单帮助器方法。查看边缘版本以获得更清晰的版本实施比文档中的实施要好。
There's a view helper named
page_entries_info
which provides the info you need:Note that it's not very customizable, but you might be able to write your own simple helper method based on it. Check out the edge version for a somewhat cleaner implementation than the one from the docs.