Skip to content

paginating multiple collections with will_paginate

by admin on October 13th, 2010

Use case: I have a page with multiple post. Each post has multiple comments. I want to use the infinite_scroll jquery plugin to “paginate” through the comments and post.

Admittedly, nested pagination makes little sense until you think about it in context of having multiple infinite scrolls on a page.

Here are the bare bones.

My Post model:
def comment_pages(comment_page = 1)
self.comments.paginate( :page => comment_page, :per_page => 5 )
end

My View (haml version):
#comment_pagination= will_paginate(comments, :param_name => "comment_page_#{post.id}")

Now i have unique list that infinite scroll can use to paginate through.

From → Ruby on Rails

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS