Skip to content

Instantly share code, notes, and snippets.

@nejdetkadir
Created December 23, 2021 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nejdetkadir/18080ba5e1da2d6b22b7cb05a5a555f2 to your computer and use it in GitHub Desktop.
Save nejdetkadir/18080ba5e1da2d6b22b7cb05a5a555f2 to your computer and use it in GitHub Desktop.
How to use Devise gem with Rails 7 (devise_controller.rb)
class Users::DeviseController < ApplicationController
class Responder < ActionController::Responder
def to_turbo_stream
controller.render(options.merge(formats: :html))
rescue ActionView::MissingTemplate => error
if get?
raise error
elsif has_errors? && default_action
render rendering_options.merge(formats: :html, status: :unprocessable_entity)
else
redirect_to navigation_location
end
end
end
self.responder = Responder
respond_to :html, :turbo_stream
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment