diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-01-23 09:31:16 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-02-06 20:56:09 +0100 |
commit | 69f28a7d8dfc018b948d9f70fc65a8a1b7735b8f (patch) | |
tree | 2177c3b7cf691bb201f49b52e042a66d5ea47242 /actionpack/lib/action_dispatch/routing | |
parent | 99bb2fd892a2a876ba0f4017bd3cc87033a4deb3 (diff) | |
download | rails-69f28a7d8dfc018b948d9f70fc65a8a1b7735b8f.tar.gz rails-69f28a7d8dfc018b948d9f70fc65a8a1b7735b8f.tar.bz2 rails-69f28a7d8dfc018b948d9f70fc65a8a1b7735b8f.zip |
ruby constant syntax is not supported as routing `:controller` option.
The current implementation only works correctly if you supply the `:controller`
with directory notation (eg. `:controller => 'admin/posts'`).
The ruby constant notation (eg. `:controller => 'Admin::Posts`) leads to unexpected problems with `url_for`.
This patch prints a warning for every non supported `:controller` option. I also added documentation how
to work with namespaced controllers. The warning links to that documentation in the rails guide.
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 82ef1d0333..34f5f80d4d 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -246,6 +246,12 @@ module ActionDispatch raise ArgumentError, "missing :action" end + if controller.is_a?(String) && controller !~ /\A[a-z_\/]+\z/ + message = "'#{controller}' is not a supported controller name. This can lead to potential routing problems." + message << " See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use" + raise ArgumentError, message + end + hash = {} hash[:controller] = controller unless controller.blank? hash[:action] = action unless action.blank? |