Agile Web Development with Rails 7: method: :delete not working (220) [solved]

I found that <li><%= button_to 'Logout', logout_path, method: :delete %></li> was calling the non-existent get route instead of the delete route.

Changing to this correctly calls the delete route:

<li><%= link_to 'Logout', logout_path, data: { turbo_method: :delete } %></li>

It’s working for me. The markup that is generated looks like the following:

<form class="button_to" method="post" action="/logout">
  <input type="hidden" name="_method" value="delete" autocomplete="off">
  <button type="submit">Logout</button>
  <input type="hidden" name="authenticity_token" value="93ee1GV1XHe-_BroB_DDYRxB2JBHYxdKNfPj7oYdJLR4B-uskKtPR0pvlBJgwp8tVI1Beb-sISg6pYuDH-qpzg" autocomplete="off">
</form>