Skip to content
Browse files

"controllers" should be a valid path name

  • Loading branch information...
1 parent 7e61a32 commit 8ed1a562c6293c81c894f3fe55fe88610c4f6caa @tenderlove tenderlove committed
Showing with 11 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +10 −0 actionpack/test/dispatch/routing_test.rb
View
2 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -117,7 +117,7 @@ def normalize_options!(options)
options[$1.to_sym] ||= /.+?/
end
- if path_without_format.match(':controller')
+ if path_pattern.names.map(&:to_sym).include?(:controller)
raise ArgumentError, ":controller segment is not allowed within a namespace block" if scope[:module]
# Add a default constraint for :controller path segments that matches namespaced
View
10 actionpack/test/dispatch/routing_test.rb
@@ -99,6 +99,16 @@ def test_namespace_with_controller_segment
end
end
+ def test_namespace_without_controller_segment
+ draw do
+ namespace :admin do
+ get 'hello/:controllers/:action'
+ end
+ end
+ get '/admin/hello/foo/new'
+ assert_equal 'foo', @request.params["controllers"]
+ end
+
def test_session_singleton_resource
draw do
resource :session do

0 comments on commit 8ed1a56

Please sign in to comment.
Something went wrong with that request. Please try again.