Ruby on Rails:默认 will_paginate 到结果的最后一页
有没有一种简单的方法,默认 will_paginate 到最后一页?我想向用户展示最新添加的内容并允许浏览以前的结果页面...
Is there an easy way, to default will_paginate to last page? I would like to show user latest addition and allow to browse previuos pages of results...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需按时间倒序排列您的查询即可。
Just order your query so that it's in reverse chronological order.
正确的方法是反转排序顺序,即添加
到分页调用中。用户期望在开头显示“最新添加内容”,在接下来的页面上显示较旧的内容。
The proper way to do it is to reverse the sorting order, i.e. add
to your paginate call. User would expect the "latest addition" on the beginning, and older ones on the following pages.
这个解决方案是我发现的最合理的想法:
http://groups.google。 com/group/will_paginate/browse_thread/thread/63b8d295f25085c2
This solution was the most resonable idea I found:
http://groups.google.com/group/will_paginate/browse_thread/thread/63b8d295f25085c2