redirect_to(options = {}, response_status = {}) protected
Redirects the browser to the target specified in options. This parameter can take one of three forms:
- Hash - The URL will be generated by calling url_for with the options.
- Record - The URL will be generated by calling url_for with the options, which will reference a named URL for that record.
- String starting with protocol:// (like http://) - Is passed straight through as the target for redirection.
- String not containing a protocol - The current protocol and host is prepended to the string.
- :back - Back to the page that issued the request. Useful for forms that are triggered from multiple places. Short-hand for redirect_to(request.env["HTTP_REFERER"])
Examples:
The redirection happens as a “302 Moved” header unless otherwise specified.
Examples:
It is also possible to assign a flash message as part of the redirection. There are two special accessors for commonly used the flash names alert and notice as well as a general purpose flash bucket.
Examples:
When using redirect_to :back, if there is no referrer, RedirectBackError will be raised. You may specify some fallback behavior for this case by rescuing RedirectBackError.
comments powered by Disqus