Skip to content
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

Custom redirect_status only available when a flash YAML file exist #239

Closed
taq opened this issue Jan 13, 2023 · 5 comments
Closed

Custom redirect_status only available when a flash YAML file exist #239

taq opened this issue Jan 13, 2023 · 5 comments

Comments

@taq
Copy link

taq commented Jan 13, 2023

I was having some issues with redirection on Firefox, getting a "Error: Form responses must redirect to another location" from turbo, and noticed that seems I needed a 302 redirect different status. As said on the README:

config.responders.redirect_status = :see_other

This would solve my problem, but I was not getting the custom redirect status working. I checked on console via

Rails.application.config.responders.redirect_status

And got :see_other, ok, but it was still not working (on Chrome everything was fine). Then I saw that on the responders.rb file ActionController::Responder.redirect_status is located inside the initializer "responders.flash_responder" block, setting the cattr_accessor :redirect_status. As I didn't have a flash YAML file, the default one installed with the generator is for en and I'm using pt-BR as my app language, I suppose the redirect_status attribute was never set.

When I created the pt-BR flash file, everything worked. So, I'm not sure if is just code on the wrong place, if the flash file is mandatory or I am missing something. Maybe running the app always with en set with the file created by the generator can miss this point on other languages.

Thanks!

@taq
Copy link
Author

taq commented Jan 13, 2023

Uh, sorry. Seems even with the en file code was changed. But I still getting a Completed 302 Found when using respond_with after an update. Is there any way to force/check :see_other?

@carlosantoniodasilva
Copy link
Member

@taq thanks for your report.

The redirect_status config should apply even though it's inside that initializer named responders.flash_responder, I believe that's just a naming that was used by the time since the only configs responders had were related to the flash responder, this is the first one that is for the responders themselves.

I was just testing redirect_status with a new error_status branch I'm working on #240, and it appears to be working. I can change it via the config and restart Rails, which seems to pick up the change to the status I configure it to.

Which responders version are you using? The redirect_status is only on main, not a released version, so make sure you're pointing to that. (I hope to release a new version soon, once I finish my changes and ensure they're working as expected)

@taq
Copy link
Author

taq commented Jan 27, 2023

Hey @carlosantoniodasilva , thanks for your answer.

Using responders (3.0.1)

@carlosantoniodasilva
Copy link
Member

@taq gotcha, so redirect_status is really only available on main branch right now, I'm hoping to cut a new release soon. If you wouldn't mind giving that one a try, let me know if you run into any issues.

(You can also try out my branch if you want the 422 Unprocessable Entity behavior, by configuring error_status as well -- see the description there, it's going to main soon for the release I'm planning.)

@taq
Copy link
Author

taq commented Jan 27, 2023

Thanks 👍🏻🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants