Leave your answer in the comments!
Given this routes file:
Omg::Application.routes.draw do
match ':controller(/:action(/:id(.:format)))'
end
And these controllers:
module Admin
class UserController < ActionController::Base
def show
end
end
end
class AdminController < ActionController::Base
def show
end
end
class Products < ActionController::Base
def show
end
end
What controller do these urls route to?
/products/show/10
/products/show
/admin/user/show/10
/admin/user/show
It's my fault: rails/rails@b802a0d
However, without that commit it would break backward compatibility for namespaced controllers. The regexp constraint is non-greedy by default, otherwise it would swallow all of the path as the controller name. This is because the other segments are optional and this causes the strange result for 4. I added a note about dynamic controller segments in the routing guide: http://guides.rubyonrails.org/routing.html#dynamic-segments.
Adding two routes, one with a custom regexp constraint should give more reasonable results:
@oriolgual The thing to remember is that Rack::Mount is doing the route recognition and it has no knowledge of controllers, actions, etc and it doesn't look at what is in the app folder. To Rack::Mount :controller is no different than an other dynamic segment like :id, :user_id, etc. All it does is match patterns - once that pattern is matched it's handed back to ActionDispatch to call the appropriate controller/action.