I currently have a comment model that is placed under the micropost, and both of them appear on the same page. The problem is that both of them are displayed on the same page, and both of them are paginated, and I'm trying to move on to facebook's micro-posting approach. Here is the question below:
Links for both pagination turn into href="/users/2?page=2"
, not href="/users/2/micropost?page=2"
or href="/users/2/comment?page=2"
. I am not sure how to solve this problem. Here are some of my code. All suggestions are welcome!
Micropost Render HTML
<table class="microposts"> <% if microposts.any? %> <%= render microposts %> <%= will_paginate microposts, :page_links => false %> <% else %> <div class="EmptyContainer"><span class='Empty'>Add a thread!</span></div> <% end %> </table>
HTML Comment Section
<div id='CommentContainer-<%= micropost.id%>' class='CommentContainer Condensed2'> <div class='Comment'> <%= render :partial => "comments/form", :locals => { :micropost => micropost } %> </div> <div id='comments'> <% comments = micropost.comments.paginate(:per_page => 5, :page => params[:page]) %> <%= render comments %> <%= will_paginate comments, :class =>"pagination" %> </div> </div>
User controller for browse page
def show @user = User.find(params[:id]) @comment = Comment.find(params[:id]) @micropost = Micropost.new @comment = Comment.new @comment = @micropost.comments.build(params[:comment]) @comments = @micropost.comments.paginate(:page => params[:page], :per_page => 5) @microposts = @user.microposts.order('created_at DESC').paginate(:per_page => 10, :page => params[:page]) respond_to do |format| format.html format.js end end
source share