diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-12 16:21:34 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-12 16:21:34 -0700 |
commit | 216309c16519d94a9e0aebf758029a78696ab8d6 (patch) | |
tree | db271a9f9cb8ddf9aed72e125fe867d0e10d40e0 /actionpack/lib/action_controller/new_base/redirector.rb | |
parent | 72ca7c591c9eace150c0ebab1633d691a1ef12cf (diff) | |
download | rails-216309c16519d94a9e0aebf758029a78696ab8d6.tar.gz rails-216309c16519d94a9e0aebf758029a78696ab8d6.tar.bz2 rails-216309c16519d94a9e0aebf758029a78696ab8d6.zip |
Implemented redirects and partial rendering in new base.
Diffstat (limited to 'actionpack/lib/action_controller/new_base/redirector.rb')
-rw-r--r-- | actionpack/lib/action_controller/new_base/redirector.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/new_base/redirector.rb b/actionpack/lib/action_controller/new_base/redirector.rb new file mode 100644 index 0000000000..ff7b74341c --- /dev/null +++ b/actionpack/lib/action_controller/new_base/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? + response.status = status + response.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
\ No newline at end of file |