rails 7 integration guide?
Is there an integration guide for rails 7?
@mices , you want an integration guide for rails 7 with devise?
yes because i get the following error: -0400 Rack app ("GET /" - (127.0.0.1)): #<LoadError: cannot load such file -- /home/.../.rvm/gems/ruby-3.0.1/gems/turbo-rails-1.1.1/app/channels/turbo/streams>
Watch issue https://github.com/heartcombo/devise/issues/5446. This article provides a good workaround.
I think the solution is to run rails turbo:install:redis I got stuck on something else on the same app so I haven't had a chance to try it yet
The article and GoRails referenced fixes referenced are excellent. Based on my experience, it does not solve for account cancellation. I fixed it here:
# TurboDeviseController::Responder.to_turbo_stream rescue block
if has_errors? && default_action
render rendering_options.merge(formats: :html, status: :unprocessable_entity)
# this is the condition added to handle user account cancellation
elsif @controller.controller_name == "registrations" && @controller.action_name == "destroy"
# avoid missing template after user destruction
redirect_to "/"
else
redirect_to navigation_location
end
You also need to modify the view so it doesn't blow past the confirm with form: { data: { turbo_confirm: "Are you sure?" }
devise/registrations/edit.html.erb
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), form: { data: { turbo_confirm: "Are you sure?" } }, method: :delete %></p>
Watch issue #5446. This article provides a good workaround.
We were using this fix in our repository too, but responders bumped to v3.1.0 which changed rendering_options to error_rendering_options, so you have to just replace the variable name in the TurboDeviseController to get it working:
class TurboDeviseController < 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 error_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
Hey all, please checkout https://github.com/heartcombo/devise/pull/5548, we're wrapping up the changes to make Devise compatible with Turbo, which shouldn't require those additional overrides / workarounds. Hopefully that should all work out of the box, but if you run into any issues, let us know. That should be merged to main soon too.