diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index d419a09ec5..b0f713b049 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -1029,7 +1029,8 @@ module ActionController #:nodoc: # RedirectBackError will be raised. You may specify some fallback # behavior for this case by rescuing RedirectBackError. def redirect_to(options = {}, response_status = {}) #:doc: - + raise ActionControllerError.new("Cannot redirect to nil!") if options.nil? + if options.is_a?(Hash) && options[:status] status = options.delete(:status) elsif response_status[:status] diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb index 5642792ca2..571d5b1f5a 100755 --- a/actionpack/test/controller/redirect_test.rb +++ b/actionpack/test/controller/redirect_test.rb @@ -77,6 +77,10 @@ class RedirectController < ActionController::Base redirect_to Workshop.new(5, true) end + def redirect_to_nil + redirect_to nil + end + def rescue_errors(e) raise e end def rescue_action(e) raise end @@ -215,6 +219,13 @@ class RedirectTest < Test::Unit::TestCase get :redirect_to_new_record assert_equal "http://test.host/workshops", redirect_to_url end + + def test_redirect_to_nil + assert_raises(ActionController::ActionControllerError) do + get :redirect_to_nil + end + end + end module ModuleTest