diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-08-06 19:52:11 -0300 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-08-06 19:52:11 -0300 |
commit | bd6b61be88dfe6eb1ff1dcc5c17542d804a842c7 (patch) | |
tree | 13be5181476dc71aca97bbefb795eeb814949e0e /actionpack/lib/action_controller/metal/redirector.rb | |
parent | 52798fd479d4acbf823d093b03bdd1acf8e86b62 (diff) | |
download | rails-bd6b61be88dfe6eb1ff1dcc5c17542d804a842c7.tar.gz rails-bd6b61be88dfe6eb1ff1dcc5c17542d804a842c7.tar.bz2 rails-bd6b61be88dfe6eb1ff1dcc5c17542d804a842c7.zip |
Rename /base to /metal and make base.rb and metal.rb top-level to reflect their module locations
Diffstat (limited to 'actionpack/lib/action_controller/metal/redirector.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal/redirector.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/redirector.rb b/actionpack/lib/action_controller/metal/redirector.rb new file mode 100644 index 0000000000..20060b001f --- /dev/null +++ b/actionpack/lib/action_controller/metal/redirector.rb @@ -0,0 +1,19 @@ +module ActionController + class RedirectBackError < AbstractController::Error #:nodoc: + DEFAULT_MESSAGE = 'No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify request.env["HTTP_REFERER"].' + + def initialize(message = nil) + super(message || DEFAULT_MESSAGE) + end + end + + module Redirector + def redirect_to(url, status) #:doc: + raise AbstractController::DoubleRenderError if response_body + logger.info("Redirected to #{url}") if logger && logger.info? + self.status = status + self.location = url.gsub(/[\r\n]/, '') + self.response_body = "<html><body>You are being <a href=\"#{CGI.escapeHTML(url)}\">redirected</a>.</body></html>" + end + end +end |