aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrek Glowacki <trek.glowacki@gmail.com>2011-08-16 16:27:07 -0400
committerTrek Glowacki <trek.glowacki@gmail.com>2011-08-16 16:27:07 -0400
commitdde5b8737bf7ec666f96ae04479074dfae7a63d9 (patch)
tree5aac10080bb43e47b24d54acb199f665784299a1
parent590239156714c03ad525b2248a11a3f34da3aa6a (diff)
downloadrails-dde5b8737bf7ec666f96ae04479074dfae7a63d9.tar.gz
rails-dde5b8737bf7ec666f96ae04479074dfae7a63d9.tar.bz2
rails-dde5b8737bf7ec666f96ae04479074dfae7a63d9.zip
When a route references a missing controller, raise ActionController::RoutingError with a clearer message
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb10
-rw-r--r--actionpack/test/controller/routing_test.rb10
2 files changed, 17 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 11228c597d..15a6415342 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -556,9 +556,13 @@ module ActionDispatch
dispatcher = dispatcher.app
end
- if dispatcher.is_a?(Dispatcher) && dispatcher.controller(params, false)
- dispatcher.prepare_params!(params)
- return params
+ if dispatcher.is_a?(Dispatcher)
+ if dispatcher.controller(params, false)
+ dispatcher.prepare_params!(params)
+ return params
+ else
+ raise ActionController::RoutingError, "A route matches #{path.inspect}, but references missing controller: #{params[:controller].camelize}Controller"
+ end
end
end
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 5bf68decca..3602c8a9e3 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -902,6 +902,16 @@ class RouteSetTest < ActiveSupport::TestCase
end
end
+ def test_route_error_with_missing_controller
+ set.draw do
+ get "/people" => "missing#index"
+ end
+
+ assert_raise(ActionController::RoutingError) {
+ set.recognize_path("/people", :method => :get)
+ }
+ end
+
def test_recognize_with_encoded_id_and_regex
set.draw do
match 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/