turbo_method: :delete not working for destroying users in Rails 7

114 views Asked by At

Can anyone tell me why the following is not working in Rails 7?

<%= link_to "delete", user, data: {  turbo_method: :delete } %>

The expected action was a DELETE request routed to the destroy action from the UsersController. The result was a GET request (GET /users/1) routed to the show action.

I have also tried:

data: { turbo: true, turbo_method: :delete }
data: { "turbo-method": :delete }
data: { "turbo_method": :delete }  

I have resources :users in routes.rb with rails routes indicating:

user GET    /users/:id(.:format)     users#show                                                                    
     PATCH  /users/:id(.:format)     users#update                                                                      
     PUT    /users/:id(.:format)     users#update                                                                         
     DELETE /users/:id(.:format)     users#destroy      

Running:

ruby 3.2.2 
rails 7.1.1
turbolinks 5.2.1

In previous version of rails this was simply method: :delete, but apparently in Rails 7 the more complicated the better.

0

There are 0 answers