Rails 7 and Devise Issue with Sign Out

This issue is not specifically related to Devise; well it is. Let me explain.

Your old sign out link:

<%= link_to "Sign out", destroy_user_session_path, method: delete %>

That is not going to work in Rails 7 due to turbo streams.

You have to change it to:

<%= link_to "Sign out", destroy_user_session_path, data: { turbo_method: :delete" } %>

It's a subtle change but it's fundamental.

If you are also using Rails Scaffold to generate your features, you will have to change the delete link that is shipped by default. As of January 19th 2022, Rails will use something like this:

<%= link_to "Delete", destroy_post_path, method: delete %>

When you try to delete a post, you will not see any change in the page. You ned to change the method and insert it into data and change the method to turbo_method just like the example above.

Then you have your delete function back!

Subscribe to Chim Kan - Startups, Fintech, Digital Transformation and Products

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe