Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Paginating A Post with fragments of comments
5 Posts
Paginating A Post with fragments of comments

Im glad to help, Well the best way for ajax pagination in my opinion is the one that mislav sugests, follow http://wiki.github.com/mislav/will_paginate/ajax-pagination for the instructions. I also have an example app with many topics including ajax paination with some search functionality. You can download that app at http://github.com/gusortiz/acts_as_seekable_example/tree/master. I hope that helps.

Greetings,

as the progress goes on,from this instructions => "http://weblog.redlinesoftware.com/2008/1/30/willpaginate-and-remote-links for ajax pagination", din't quite go well. The whole html page renders again, on top of the existing one. anyone has clue on this?..thanks in advance.

Greetings,

hi, that fix my problem. again thank you very much. just one thing, when i try .paginate(params), it gave me an error that it needs :page params. instead, i did .paginate(:page => params[:page]), that did the trick, plus, i move the control to the model of how many posts should be fetch ..and, yes, after examining this, and getting well without ajax, i will move on ajax pagination. again, thank you very much again. this is a big help. thank you

Maybe you should fetch the comments in the controller because will_paginate needs the :page param. Try this.

def show
  @post = Post.find(params[:id])
  @comments = @post.comments.paginate(params)
  respond_to do |format|
    format.html # show.html.erb
    format.xml  { render :xml => @post }
  end
end

And in your view

   params %>
   @comments %>
I sugest that you use the ajax pagination, I think this should do the trick.

Greetings,

I had successfully create a page for Posts that has_many Comments associations, and submitting a Comment to the post via ajax. but, i have a problem. my post page has so many comments that scrolling page down is very long if i have many comments. I tried using mislav-will_paginate, but it just seems to be not working. it just shows the links, but it doesn't paginate the comments.

my app has a Post and Comments associations. on my Post#show(views) i render my comments from a partial in my Comments views using this (_comment.html.erb) template file to my Post#show template.

@post.comments %>

from that Post#show page, it just renders all the comments associated to that post. how do i paginate them so that making my post page shows only some few pages and a pagination. sorry for the trouble again, thank you..

then on my Post#show controller, i just use the normal codes

def show

@post = Post.find(params[:id])
respond_to do |format|
  format.html # show.html.erb
  format.xml  { render :xml => @post }
end

end

5 Posts
Login to add your message