Home Error when delete comment Ruby on Rails
Reply: 0

Error when delete comment Ruby on Rails

user1236 Published in May 20, 2018, 9:55 am

When I delete comment I see

undefined method 'each' for nil:NilClass

Also, the user cannot delete his account if has posted... It makes the error.

This is code

<p id="notice"><%= notice %></p>


      <th colspan="3"></th>

    <% @comments.each do |comment| %>
        <td><%= comment.link_id %></td>
        <td><%= comment.body %></td>
        <td><%= comment.user %></td>
        <td><%= link_to 'Show', comment %></td>
        <td><%= link_to 'Edit', edit_comment_path(comment) %></td>
        <td><%= link_to 'Destroy', comment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
    <% end %>


<%= link_to 'New Comment', new_comment_path %>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.304813 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO