Home > Mobile >  Delete link sends Get request instead of Delete Rails 7
Delete link sends Get request instead of Delete Rails 7

Time:05-24

<%= 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)

CodePudding user response:

You need to replace [task.list, task], with the path like so: task_path(task) (or whatever your resource path is)

CodePudding user response:

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

  • Related