I want to delete a record that is stored in a table using a link right next to the table data. The error I come up with is:
No route matches [GET] "/carlogs/destroy"
My destroy method:
def destroy
@carlog= CarLog.find(params[:id])
@carlog.destroy()
redirect_to show_path(@carlog)
end
Part of the view code containing the Delete link:
<% @carlogs.each do |car| %>
<tr>
<td><%= car.id %></td>
<td><%= car.plate_number %></td>
<td><%= car.brand %></td>
<td><%= car.slot_number %></td>
<td><%= car.is_taken %></td>
<td><%= car.created_at %></td>
<td><%= link_to "Delete", show_path(car), method: :delete, data:
{confirm: "Are you sure?"} %>
</tr>
<% end %>
rake routesto see the correct path for deleting object.