Get Devise Working with Turbo in Rails 7 - YouTube

03-Nov-2022 1326
As mentioned in the video introducing this epic, Devise does not work correctly with the default Rails 7 configuration of Hotwire (Stimulus and Turbo). In this video we implement some work-arounds mentioned in Devise issues (including 5446, 5513). One way to solve the problem would be to disable Turbo on the forms in the Devise views. Although that's a potenitally viable solution, we decide instead to add a few patches that fix the Turbo issues and allow us to get the app working as intended. All of this is technical debt that we will need to unwind when a viable fix gem version is released, but it solves our problem.This video covers:00:00:12 Introduction00:01:18 Demonstration of the problems (no flash messages, no feedback if you fill out a form incorrectly)00:05:08 Fix flash messages by adding turbo_stream to navigational formats in configuration00:07:02 Demonstrate still no feedback on form errors00:08:45 Copy controller code from Devise Auth Setup in Rails 7 article for TurboDeviseController and walk through code00:13:15 Configure the parent_controller to match the TurboDeviseController we just created00:16:05 Add TurboFailure app and alter Warden configuration to use it00:18:59 Manually test changes00:22:35 Add a card to the project to make sure to test unhappy path with system tests 00:24:56 Fix RuboCop offenses00:28:09 Run tests, push, update issue and project.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle