I have Post model, and loop for display Post in the index page. I have Comment which belongs to Post, so In the show Post page I have used loop <% @comments.each do |comment| %> <%= comment.body %> <% end %>. But the post has a Response, so when I write "loop response in the loop comment" after clicking Add Response I have an alert
The response has successfully added
but it doesn't show under the Comment, i think that it's broken loop:
My code in the post#show
<% @comments.each do |comment| %>
<p> Author: <%= comment.user.nickname %></p>
<p><%= comment.body %></p>
<%= link_to "Add a response to comment!",
new_post_comment_response_path(@post, comment) %>
<% @responses.each do |response| %>
<%= response.body_response %>
<% end %>
<% end %>
Is it wrong?
@responses?