Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix GH #4720. Routing problem with nested namespace and already camel…

…ized controller option.
  • Loading branch information...
commit 203b88f99848454680ce5554b1cb38b6f4dee11b 1 parent e6c98b8
@kennyj kennyj authored
View
5 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -31,6 +31,7 @@ def call(env)
end
def prepare_params!(params)
+ normalize_controller!(params)
merge_default_action!(params)
split_glob_param!(params) if @glob_param
end
@@ -66,6 +67,10 @@ def dispatch(controller, action, env)
controller.action(action).call(env)
end
+ def normalize_controller!(params)
+ params[:controller] = params[:controller].underscore if params.key?(:controller)
+ end
+
def merge_default_action!(params)
params[:action] ||= 'index'
end
View
26 actionpack/test/dispatch/routing_test.rb
@@ -2449,6 +2449,32 @@ def test_missing_routes_are_still_missing
end
end
+class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
+ module ::Admin
+ class StorageFilesController < ActionController::Base
+ def index
+ render :text => "admin/storage_files#index"
+ end
+ end
+ end
+
+ DefaultScopeRoutes = ActionDispatch::Routing::RouteSet.new
+ DefaultScopeRoutes.draw do
+ namespace :admin do
+ resources :storage_files, :controller => "StorageFiles"
+ end
+ end
+
+ def app
+ DefaultScopeRoutes
+ end
+
+ def test_controller_options
+ get '/admin/storage_files'
+ assert_equal "admin/storage_files#index", @response.body
+ end
+end
+
class TestDefaultScope < ActionDispatch::IntegrationTest
module ::Blog
class PostsController < ActionController::Base
Please sign in to comment.
Something went wrong with that request. Please try again.