-
-
Save Matt-Yorkley/b333cb7d61827aee8f8f5d111567bac8 to your computer and use it in GitHub Desktop.
Devise workarounds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/config/routes.rb | |
Rails.application.routes.draw do | |
root to: "home#index" | |
devise_for :users, controllers: { | |
sessions: "users/sessions" # Override the sessions controller | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment