paginating multiple collections with will_paginate
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.