Question:how to paginate comments?

hello again,

i'm trying to paginate comments with will_paginate in order, newest on
top, and i'm using the sample script from acts_as_commentable in my

def add_comment
      commentable_type = params[:commentable][:commentable]
      commentable_id = params[:commentable][:commentable_id]
      # Get the object that you want to comment
      commentable = Comment.find_commentable(commentable_type,

      # Create a comment with the user submitted content
      comment =[:comment])
      # Assign this comment to the logged in user
      comment.user_id = current_user

      # Add the comment
      commentable.comments << comment

      redirect_to :action => "show",
      :id => commentable_id

as well as :

  def show_comment
    @post = Post.paginate :per_page =>10, :page => params[:page],
    :order => "DESC"
i have a partial that shows just the comments to the post

<%= @post.comments%>
<%= will_paginate @post.comments %>

and i get this msg:
undefined method `page_count' for #<Class:0x4a7601c>

so my question is how do i paginate comments for specific posts?

thank you guys!

i'm a bit vconfused about your code, do you want to paginate posts and
"sub-paginate" the comments for each?!?

i guess your show_comments method should rather get 1 post, and
paginate the comments for this post.
it *should* work like this, though i didn't test it.

@post = Post.find(params[:id])
@comments = @post.comments.paginate :per_page => 10, :page =>
params[:page], :order => " created_at DESC"
<%= will_paginate @comments %>

i use a seperate variabel for the comments, as the paginate method
doesn't return a simple array but a will_paginate object (that extends
Array if i recall correctly)
Give it a shot.