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.
On 8 Feb., 06:49, Richard Yoo
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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
> controller:
>
> 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,
> commentable_id)
>
> # Create a comment with the user submitted content
> comment = Comment.new(params[: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
> end
>
> as well as :
>
> def show_comment
> @post = Post.paginate :per_page =>10, :page => params[:page],
> :order => "DESC"
> end
> 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!
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---