'Devise destroy_user_session not working
I have 2 different calls to the same Devise method: destroy_user_session.
The working one is done with a very basic approach and lead to the following HTML code:
<a rel="nofollow" data-method="delete" href="/users/sign_out">Logout</a>
Them I made a more fancy one, with better UI, but still the same Rails App (so no change, only the resulting HTML is different):
<a class="tip" data-confirm="You are going to be disconnected" data-title="Logoff" rel="nofollow" data-method="delete" href="/users/sign_out" data-original-title="" title=""><i class="fa fa-power-off"></i></a>
While both are using the same method: delete to destroy current user session the second one returns No route matches [GET] "/users/sign_out".
Adding a GET route for /users/sing_out can be an option but not clean as it has to be a DELETE call.
Solution 1:[1]
For Rails 7, you will need to use the following instead of just method: :delete:
<%= link_to "Sign Out", destroy_user_session_path, data: { "turbo-method": :delete } %>
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 | thewoolleyman |
