An Interest In:
Web News this Week
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
February 21, 2022 07:41 pm GMT
Original Link: https://dev.to/spaquet/rails-7-devise-log-out-d1n
Rails 7 Devise Log out
A Quick and Dirty way to get the redirection working on Logout when using Devise in a Rails 7 app.
You probably have noticed that most of the redirects in Devise a somehow broken. This is due to the way Turbo interfere with them as it catches the 200 status code.
There are already a lot of posts explaining how to patch this while waiting for an official release. But, if your main issue is about the "redirect on log out" not working, then you can easily fix this.
Instead of calling destroy_user_session_path
in a link_to
, call it inside of a button_to
Here is the full code:
<%= button_to( "Log Out", destroy_user_session_path, method: :delete ) %>
And Voil! This simple hack enables your users to be redirected to the root_path of your app in seconds.
Original Link: https://dev.to/spaquet/rails-7-devise-log-out-d1n
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To