Merge pull request #2549 from trek/RoutingErrorForMissingControllers

When a route references a missing controller, raise ActionController::RoutingError with clearer message
This commit is contained in:
Aaron Patterson 2012-05-21 11:00:43 -07:00
commit 513a0525c2
2 changed files with 17 additions and 3 deletions

@ -663,9 +663,13 @@ def recognize_path(path, environment = {})
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

@ -1037,6 +1037,16 @@ def test_route_constraints_with_options_method_condition_is_valid
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
get 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/