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

No redirect_to :back? #649

Closed
vlad-at-work opened this issue Oct 3, 2016 · 7 comments
Closed

No redirect_to :back? #649

vlad-at-work opened this issue Oct 3, 2016 · 7 comments

Comments

@vlad-at-work
Copy link

I checked out the source and it doesn't seem like that's possible. Is this something that's PR worthy? Should a current template be re-rendered instead or something?

@cllns
Copy link
Member

cllns commented Oct 3, 2016

Looks like Rails now advocates using redirect_back with a required fallback location param, instead of redirect_to :back. I think this a better approach, since not all web clients send the Referer header, and we need to have a back-up plan.

I'm open to this, but it's also really easy for people to implement themselves. Something like: redirect_to request.headers["Referer"] || fallback_url

What do others think?

@TiteiKo
Copy link
Contributor

TiteiKo commented Oct 26, 2016

I agree that it's easy to implement it if needed, but it would be a good idea to document it somewhere. I've not had a lot of use cases where a redirect back was necessary...

@vladdypwnz basically, when a submission fails, you should re-render the template, not redirect back, otherwise you'll lose your form errors

One of the only redirect back use case is on user login within the page where he must go back, but it's better handled with either a session or url param, in case the user enters a wrong password...

@runlevel5
Copy link
Member

I am with @TiteiKo on this. It is pretty trivial to implement. The question is should we? There are certain patterns that Rails advocates that has proven not-so-good practice. I am open for more input if this pattern proves useful.

@cllns
Copy link
Member

cllns commented Oct 27, 2016

I also agree with @TiteiKo. We should document this feature, not implement it. Implementing a half-baked (because it requires a fallback URL for when 'referer' isn't set) solution seems like a bad idea. The doc note could go here: http://hanamirb.org/guides/actions/control-flow/ ?

@theCrab
Copy link
Contributor

theCrab commented Nov 22, 2016

@cllns Do you want me to include this in the docs. I agree this is too trivial for a framework support. It should be left to dev to implement really.

@cllns
Copy link
Member

cllns commented Nov 22, 2016

Go for it @theCrab :) Thanks

@jodosha jodosha removed the feature label Nov 29, 2016
@jodosha
Copy link
Member

jodosha commented Nov 29, 2016

@vladdypwnz

Should a current template be re-rendered instead or something?

yes


Because you all voted against it, I'm removing the feature label and closing it.

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

No branches or pull requests

6 participants