Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7594557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:26:51+00:00 2026-05-30T21:26:51+00:00

The current page that I have been working on is a page where a

  • 0

The current page that I have been working on is a page where a user can create a comment under a specific micropost. All the microposts are shown on the same page and those microposts are paginated. Under each specific micropost, there are comments and those comments should be paginated and the issue I am currently having is that the pagination only happens when the HTML code is this:

HTML

<div id='comments'>
<%=render @comments %>
<%= will_paginate @comments, :class =>"pagination" %>
</div>

But the thing is when it is like that only the comments for the first micropost will show up on every single micropost rather than the specific micropost comments. So I figured why not put the code like this:

HTML

<div id='comments'>
<%=render micropost.comments %>
<%= will_paginate @comments, :class =>"pagination" %>
</div>

This basically set all the specific comments in the right micropost BUT it didn’t paginate but the pagination links showed, so I figured putting this would work but it didn’t, got an error:

HTML

<div id='comments'>
<%=render micropost.comments %>
<%= will_paginate micropost.comments, :class =>"pagination" %>
</div>

I am very confused and unsure what to do and yes the micropost is suppose to have no @
I would appreicate any suggestions that would help! Thank you!

My User#Show

User Controller

class UsersController < ApplicationController
  def show
    @user = User.find_by_id(params[:id])
    @school = School.find(params[:id])
    @micropost = Micropost.new
    @comment = Comment.new
    @comment = @micropost.comments.build(params[:comment])
    @comments = @micropost.comments.paginate(:page => params[:page], :per_page => 10)
    @microposts = @user.microposts.paginate(:per_page => 10, :page => params[:page])
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:26:52+00:00Added an answer on May 30, 2026 at 9:26 pm

    This will work, but the fact that you need to do an assignment inside your view tells you this is probably not the way to do it:

    <div id='comments'>
      <% comments = micropost.comments.paginate(:per_page => 10, :page => params[:page]) %>
      <%= render comments %>
      <%= will_paginate comments, :class =>"pagination" %>
    </div>
    

    Do realize that the micropost & comments both use the same page parameter. So that if you want to view the second page of comments of any of the given microposts you will also switch to the second page of microposts. I would reconsider showing all this information on the same page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page that always needs to stay current. I do not
I'm building an authors page for my Wordpress blog that lists all the current
I have been working on a shop that is built in Python on the
I have been working on a website that has to do with a subscription
On this page Ive been working on forever , I have this column headed
I'm trying to show wall posts that all users have made on a specific
So I have been working on a project for a client on their current
I'm trying to build a control logic that depends on the current gsp page
Page has menu items that would replace a 'div id=foo_(current menu item)' with 'div
How can I find the current page number in jqGrid (using jQuery of course).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.