1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

When a route references a missing controller, raise ActionController::RoutingError with a clearer message

This commit is contained in:
Trek Glowacki 2011-08-16 16:27:07 -04:00
parent 5902391567
commit dde5b8737b
2 changed files with 17 additions and 3 deletions

View file

@ -556,9 +556,13 @@ module ActionDispatch
dispatcher = dispatcher.app
end
if dispatcher.is_a?(Dispatcher) && dispatcher.controller(params, false)
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

View file

@ -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\+]+/