'Delete link sends Get request instead of Delete Rails 7
<%= link_to 'Delete', [task.list, task],
method: :delete,
data: { confirm: 'Are you sure?' } %>
Started GET "/lists/2/tasks/4" for 127.0.0.1 at 2022-05-24 13:32:16 +0500
AbstractController::ActionNotFound (The action 'show' could not be found for TasksController)
Solution 1:[1]
You need to replace [task.list, task], with the path like so: task_path(task) (or whatever your resource path is)
Solution 2:[2]
Like @TTD said, you need to do something like this: <%= link_to "Delete", task_path(@path), method: :delete, data: { confirm: "Really?" } %> 0
as you need to reference just one object
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TTD |
| Solution 2 | uzorjchibuzor |
