mercredi 16 décembre 2020

Why I can not delete object when click destroy in Rails?

I am trying to click link destroy but it going to in the page details? I use CRUD default of rails Here is the code :

tbody>
    <% @posts.each do |post| %>
      <tr>
        <td><%= post.tittle %></td>
        <td><%= post.body %></td>
        <td><%= link_to 'Show', post %></td>
        <td><%= link_to 'Edit', edit_post_path(post) %></td>
        <td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
  </tbody>

Aucun commentaire:

Enregistrer un commentaire