Rails 3 中 Kaminari 的部分分页
这是关于 Rails 3 的另一个新手问题:我有一个名为“Activity”的模型。在活动的 show.html.erb 页面上,我将属于该活动的评论显示为部分内容:
<%= render :partial => @activity.comments %>
评论的外观位于 _comment.html.erb 文件中。
我的问题:如何对 Kaminari 活动的评论进行分页?
预先非常感谢!
Here is another Newbie question on Rails 3: I have a model called "Activity". On the show.html.erb page of an activity, I show the comments that belong to this activity as a partial:
<%= render :partial => @activity.comments %>
How the comments look like is in the _comment.html.erb file.
My question: How can I paginate the comments for an activity with Kaminari?
Thanks very much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设
params[:page]
是您评论的页码。您可以执行类似@activity.comments.page(params[:page])
的操作。我建议你阅读 https://github.com/amatsuda/kaminari,自述文件几乎包含了你想要的所有内容需要。Lets assume
params[:page]
is the page number for your comments. You would do something like@activity.comments.page(params[:page])
. I suggest you read https://github.com/amatsuda/kaminari, the README contains pretty much everything you need.