Skip to content

Instantly share code, notes, and snippets.

Last active April 28, 2022 07:12
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Devise workarounds
# app/views/example/logout_button.html.erb
<%= link_to "Log out", link_to destroy_user_session_path, method: :delete %>
# app/config/routes.rb
Rails.application.routes.draw do
root to: "home#index"
devise_for :users, controllers: {
sessions: "users/sessions" # Override the sessions controller
# app/controllers/users/sessions_controler.rb
class Users::SessionsController < Devise::SessionsController
# DELETE /resource/sign_out
def destroy
# Redirect after a sign-out is successfully performed. The button has a 204 response
# that doesn't redirect or render, which doesn't play nicely with Turbo-style navigation.
# The destroy method in the parent takes a block that allows some minor customisation.
super do
return redirect_to root_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment