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 1046333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:07:51+00:00 2026-05-16T16:07:51+00:00

The following problem has been fixed, I added an ‘s’ to the end of

  • 0

The following problem has been fixed, I added an ‘s’ to the end of comments, when it should just be comment, but a new problem has arisen at the bottom of this post.

I am trying to get threaded comments for my already existing comments system by following the answer to this man’s question: Reddit-style nested/threaded/indented comments for Rails?
When I try to access my article show page, I get the following error: undefined method `children’ for #
Here’s the view from my article show page that is problematic:

<div id="comment <%= comment.id %>">
  <%= comment.title %>
  | <%= link_to "Edit Comment", edit_article_comment_path(@commentable, comment) %>
  | <%= link_to 'Delete Comment', [@commentable, comment], :confirm => "Are you sure?", :method => :delete %><br />
  <%= comment.content %><br />
  **<%= render :partial => 'comments/comment', :collection => @comments.children %>**
  <%= comment.user.name %><br /><br />
</div>

It’s the render portion that is having a problem.
If I take out the children part from the comments, I get this in my console:
The recursion never stops. I get this: Rendered comments/_form.html.erb (14.9ms) Rendered comments/_comment.html.erb (2.0ms) Rendered comments/_comment.html.erb (7.3ms) Rendered comments/_comment.html.erb (12.3ms) Rendered comments/_comment.html.erb (17.9ms) Rendered comments/_comment.html.erb (22.3ms) Rendered comments/_comment.html.erb (26.8ms) Rendered comments/_comment.html.erb (31.6ms) Rendered comments/_comment.html.erb (36.2ms) ….
I do not know why it keeps rendering.
None of the comments have children, so it should stop.
Here’s the ‘show’ part of the article controller:

def show
@article = Article.find(params[:id])
@commentable = Article.find(params[:id])
@comments = @commentable.comments.paginate(:page => params[:page])
@comment = Comment.new
@title = @article.title
end

My only explanation is that maybe there aren’t any children comments, so will_paginate does not know what to do with it, so it throws an error at me.


New Problem, I am having problem with routing for comments. I am using polymorphic associations for my comments so they can be used for different models(articles, profiles, pictures, etc.), but I do not know how to create the routing paths in my view.
Here is what I have now:

<div id="comment <%= comment.id %>">
  <%= comment.title %>
  | <%= link_to "Permalink", article_comment_path(@commentable, comment) %>
  | <%= link_to "Reply", new_article_comment_path(@commentable, @comment_child) %>
  | <%= link_to "Edit Comment", edit_article_comment_path(@commentable, comment) %>
  | <%= link_to 'Delete Comment', [@commentable, comment], :confirm => "Are you sure?", :method => :delete %><br />
  <%= comment.content %><br />
  <%= comment.user.name %><br /><br />
  <%= render :partial => 'comments/comment', :collection => @comment.children %>
</div>

There is an abundant number of pathing errors that won’t work for other models. I am using: article_comment_path, new_article_comment_path, and edit_article_comment_path. By the way, this is inside of a for each loop, which loops over an array of comments. I want something like “commentable_comment_path” or “new_commentable_comment_path”, so I can use it for my other models.

One more quick question, will this fix my “reply” link? I am not sure if I am doing that right. I want the reply link to create a comment within a comment.

Thank you so much.

  • 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-16T16:07:51+00:00Added an answer on May 16, 2026 at 4:07 pm

    parent_id as you suggest is an integer reference to an object. To get the children for an object a you would look up all objects that have a parent_id of a.id.

    As for the problem with the rendering: @comments is an array of comment objects – you have essentially asked for a page of comments by using paginate. I guess you want to render the comments themselves in which case :collection => @comments will do the job. This just means to use the partial for each item in the collection. The partial will then take care of rendering the children of each comment as per the linked answer.

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

Sidebar

Related Questions

(This question is following on from my previous problem which has been fixed (Here)
My problem is that my company's website has recently been getting the following parse
My problem is exactly same as described in following post but it hasn't been
i am looking for opinions if the following problem maybe has a better/different/common solution:
Has anyone encountered the following problem: I have IIS7 running on my computer. On
I have got the following problem since the server has safe mode turned on,
I've got following problem: (c#) There is some class (IRC bot), which has method,
Ive got the following problem. I have a model called user which has a
A colleague of mine has a problem with a sql query:- Take the following
I have following UI hierarchy Scroll View -->TableLayout-->Rows [each row has TextView+EditText] Problem Inside

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.