-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Awkward behavior around redirects & error codes #34
Comments
Would if Devise has something in place to detect all requests that come from fetch as XHR somehow, and then not do the HTML rendering if then? Maybe dive into that Devise chain and lets see if its something we have to fix there or if there's anything we can do on the turbo side. |
Related to hotwired/turbo-rails#12 Related to hotwired/turbo-rails#34 Typically, Turbo expects each FormSubmission request to result in a redirect to a new Location. When a FormSubmission request fails with an [unprocessable entity][422] response, render the response HTML. This commit brings the same behavior to `<turbo-frame>` elements. [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422
Related to hotwired/turbo-rails#12 Related to hotwired/turbo-rails#34 Typically, Turbo expects each FormSubmission request to result in a redirect to a new Location. When a FormSubmission request fails with an [unprocessable entity][422] response, render the response HTML. This commit brings the same behavior to `<turbo-frame>` elements. [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422
I remember that old turbolinks/turbolinks-classic had special code for Devise:
And Devise even has some hint here on how to use it Also temporary stucked with Devise redirects :) |
It's not working with devise yet: hotwired/turbo-rails#34 https://discuss.hotwire.dev/t/forms-without-redirect/1606
Related to hotwired/turbo-rails#12 Related to hotwired/turbo-rails#34 Typically, Turbo expects each FormSubmission request to result in a redirect to a new Location. When a FormSubmission request fails with an HTTP Status code between 400-499 or 500-599 (e.g. [unprocessable entity][422]), render the response HTML. This commit brings the same behavior to `<turbo-frame>` elements. [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422
Related to hotwired/turbo-rails#12 Related to hotwired/turbo-rails#34 Typically, Turbo expects each FormSubmission request to result in a redirect to a new Location. When a FormSubmission request fails with an HTTP Status code between 400-499 or 500-599 (e.g. [unprocessable entity][422]), render the response HTML. This commit brings the same behavior to `<turbo-frame>` elements. [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422
Related to hotwired/turbo-rails#12 Related to hotwired/turbo-rails#34 Typically, Turbo expects each FormSubmission request to result in a redirect to a new Location. When a FormSubmission request fails with an HTTP Status code between 400-499 or 500-599 (e.g. [unprocessable entity][422]), render the response HTML. This commit brings the same behavior to `<turbo-frame>` elements. [422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422
You can now render on POST using either 4xx or 5xx status codes. In Rails, you'd do: respond_to do |format|
if @room.save
format.html { redirect_to @room, notice: 'Room was successfully created.' }
format.json { render :show, status: :created, location: @room }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @room.errors, status: :unprocessable_entity }
end
end Part of 0.5.3. |
Wups, posted on the wrong issue. But you can now opt out of Turbo processing using the data-turbo=false attribute. I believe that should probably solve this? Might want to add a doc note about it. |
In case someone lands here trying to get Devise working with Turbo - there's been several workarounds/improvements suggested on Hotwire Discussion. There's even a GoRails video with instructions. |
The responders used by Devise have been updated heartcombo/responders#223 (pending a new release). Once released, the open PR for Devise can be finalised heartcombo/devise#5340 |
I'm trying to Turboify an app which uses Devise.
When I try to sign out, I expect the following to happen.
Instead, the following happens:
For my use case, I can probably fix it by overriding the Devise redirect chain -- it's annoying, but not unsolvable.
However, I can see this kind of interaction being really confusing to a naive user. It doesn't really signal what the issue is, it's just a silent failure.
The text was updated successfully, but these errors were encountered: