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 Introduction
00: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 configuration
00:07:02 Demonstrate still no feedback on form errors
00:08:45 Copy controller code from Devise Auth Setup in Rails 7 article for TurboDeviseController and walk through code
00:13:15 Configure the parent_controller to match the TurboDeviseController we just created
00:16:05 Add TurboFailure app and alter Warden configuration to use it
00:18:59 Manually test changes
00:22:35 Add a card to the project to make sure to test unhappy path with system tests
00:24:56 Fix RuboCop offenses
00:28:09 Run tests, push, update issue and project
#ruby #rails7 #rails #rubyonrails #rubygems #codecast #screencast #github #opensource #minitest #TDD #agile #NerdDice #DnD #roleplaying #softwaredevelopment #learntocode #tailwind #postgresql #rubocop #devise #turbo #controllers #gorails #betterprogramming
See other related StatelessCode videos:
Overview of Authentication Epic and Choosing Devise • Overview of Authentication Epic and Choosi...
Resources that we relied upon for this solution:
Article: Better Programming - Devise Auth Setup in Rails 7 by Nick Francisci https://betterprogramming.pub/devise-...
Video: Go Rails - How to use Devise with Hotwire & Turbo.js by Chris Oliver https://gorails.com/episodes/devise-h...
This video is CC0 - No rights reserved. (YouTube doesn't allow this option when publishing.) All code is released under the UNLICENSE. Stateless Code denies the concept of "intellectual property". Copying is not stealing.