Skip to content

Configure Devise responder for Turbo compatibility#1444

Merged
jmilljr24 merged 3 commits intomainfrom
maebeale/devise-responder-status
Mar 28, 2026
Merged

Configure Devise responder for Turbo compatibility#1444
jmilljr24 merged 3 commits intomainfrom
maebeale/devise-responder-status

Conversation

@maebeale
Copy link
Copy Markdown
Collaborator

@maebeale maebeale commented Mar 28, 2026

What is the goal of this PR and why is this important?

Follow-up to the Devise 5 upgrade (#1439) Not related to devise upgrade.

  • configure Devise's built-in responder to return Turbo-compatible HTTP status codes
  • Without this, Devise forms either need data-turbo=false workarounds or Turbo silently drops error responses (422) and redirects (303)

How did you approach the change?

  • Set config.responder.error_status = :unprocessable_entity and config.responder.redirect_status = :see_other in the Devise initializer
  • Removed data: { turbo: false } from the login form, confirmation resend form, and welcome/password-set form since Turbo can now handle these responses natively

UI Testing Checklist

  • Log in with valid credentials — redirects to dashboard
  • Log in with invalid credentials — shows error on login page
  • Request confirmation resend — shows flash message
  • Complete welcome/set-password flow — redirects after save
  • Verify no full-page reloads on the above flows (Turbo should handle them)

Anything else to add?

  • Devise 5 Devise 4.9 added native Turbo support via config.responder; this replaces the turbo: false opt-outs that were added as a stopgap

🤖 Generated with Claude Code

Devise 5 supports Turbo-aware status codes natively via responder
config. Set error_status to :unprocessable_entity and redirect_status
to :see_other so Turbo can handle Devise form responses correctly,
and remove the data-turbo=false workarounds from login, confirmation,
and welcome forms.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Use Turbo-compatible HTTP status codes
config.responder.error_status = :unprocessable_entity
config.responder.redirect_status = :see_other

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two settings are the native Devise 5 way to enable Turbo compatibility. :unprocessable_entity (422) lets Turbo re-render the form with errors, and :see_other (303) lets Turbo follow redirects on success. This replaces the need for data-turbo=false on every Devise form.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, it wasn't the upgrade to 5.0 that caused an issue. Devise 4.9 added these new config options to support turbo. Devise will generate these config options for new apps but since we already had devise, we just needed to add them manually.

@maebeale
Copy link
Copy Markdown
Collaborator Author

@jmilljr24 fyi i've started to dig in to this. i've got a tournament all day today so if you wanted to pick this up and get it across the finish line, awesome!

@jmilljr24 jmilljr24 marked this pull request as ready for review March 28, 2026 14:08
@jmilljr24 jmilljr24 merged commit 59abee8 into main Mar 28, 2026
3 checks passed
@jmilljr24 jmilljr24 deleted the maebeale/devise-responder-status branch March 28, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants