aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-11-02 14:47:03 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-11-02 14:47:03 +0000
commit4f754985d0d39a9e7831e45809b030b2b3c62d09 (patch)
tree94365183e680af76a6e1a9febe8fade7f9ae436b /actionpack/lib/action_controller/base.rb
parent49cd52a93febcef28a5ae2ed5427294ec5159548 (diff)
downloadrails-4f754985d0d39a9e7831e45809b030b2b3c62d09.tar.gz
rails-4f754985d0d39a9e7831e45809b030b2b3c62d09.tar.bz2
rails-4f754985d0d39a9e7831e45809b030b2b3c62d09.zip
Added redirect_to :back as a short-hand for redirect_to(request.env["HTTP_REFERER"])
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2848 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/base.rb')
-rwxr-xr-xactionpack/lib/action_controller/base.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 7c2f7239fa..07b9b443d2 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -727,11 +727,14 @@ module ActionController #:nodoc:
# * <tt>Hash</tt>: The URL will be generated by calling url_for with the +options+.
# * <tt>String starting with protocol:// (like http://)</tt>: Is passed straight through as the target for redirection.
# * <tt>String not containing a protocol</tt>: The current current protocol and host is prepended to the string.
+ # * <tt>:back</tt>: 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:
# redirect_to :action => "show", :id => 5
# redirect_to "http://www.rubyonrails.org"
# redirect_to "/images/screenshot.jpg"
+ # redirect_to :back
#
# The redirection happens as a "302 Moved" header.
def redirect_to(options = {}, *parameters_for_method_reference) #:doc:
@@ -745,6 +748,9 @@ module ActionController #:nodoc:
when String
redirect_to(request.protocol + request.host_with_port + options)
+
+ when :back
+ redirect_to(request.env["HTTP_REFERER"])
else
if parameters_for_method_reference.empty?