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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:17:30+00:00 2026-06-01T01:17:30+00:00

When I create a comment in my feed, rails is duplicating all the previous

  • 0

When I create a comment in my feed, rails is duplicating all the previous comments.

Comments Contoller

def create
  @post = Post.find(params[:post_id])
  @comment = @post.comments.create(params[:comment])
  redirect_to post_path(@post)
end

Posts Show

<div class="content">
<%= markdown(@post.content) %>

<ul class="comments">
<% @post.comments.each do |comment| %>
    <%= render @post.comments %>
<% end %>
</ul>

<%= render "comments/form" %>
</div>

_comment.html.erb

<li>
<%= link_to comment.name, comment.url, :title => "visit website", :target => "_blank", :rel => "nofollow" %>
<p><%= comment.body %></p>
<time><%= comment.created_at.utc.strftime("%m.%d.%Y") %></time>

<%= link_to 'X', [comment.post, comment],
                :confirm => 'Are you sure?',
                :method => :delete %>
</li>

Post.rb

has_many :comments, :dependent => :destroy

Comment.rb

belongs_to :post

After I create first comment
First Comment

After I create first comment
Second Comment

  • 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-06-01T01:17:31+00:00Added an answer on June 1, 2026 at 1:17 am

    from your code:

    <% @post.comments.each do |comment| %>
        <%= render @post.comments %>
    <% end %>
    

    this should either be:

    <%= render @post.comments %>
    

    or:

    <% @post.comments.each do |comment| %>
        <%= render comment %>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

echo $this->Form->create('Comment', array('url'=>array('controller' => 'comments', 'action' =>'add', $listposts['Post']['id']) ) ); echo $this->Form->input('post_id',array('type'=>'hidden','style'=>'width:30%','value'=>$listposts['Post']['id'])); echo $this->Form->input('name',array('style'=>'width:30%'));
A user can create a post. Posts have comments. A comment must belong to
http://developers.facebook.com/docs/reference/api/post/ In Comments -> Create section it says: You can write to the POST_ID/comments
The comment form => echo $this->Form->create('Comment',array('url'=>array('controller' => 'comments', 'action' =>'add', $listposts['Post']['id']) ) ); echo
This is the form for comment: echo $this->Form->create('Comment',array('url'=>array('controller' => 'comments', 'action' =>'add', $listposts['Post']['id']) )
I want to create an activity feed from recent article and comments in my
## COMMENT OUT below just for reference cursor.execute ( CREATE TABLE yellowpages ( business_id
I wanted to create a default value for :order : class Comment < ActiveRecord::Base
I want to create a simple message of Your comment has been posted! using
I want to create conditional comments in XSLT. But when I use this: <!--

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.