diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2010-06-26 08:15:33 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-26 10:16:30 +0200 |
commit | 9a6fc9a540cd23af3ca061cb7406a6cdd5ad4294 (patch) | |
tree | 26f964f4dc1bedda791c2a1927dba760213ac660 /actionpack | |
parent | bba19603c27e0439eb22a9bce7e3adf6924b224b (diff) | |
download | rails-9a6fc9a540cd23af3ca061cb7406a6cdd5ad4294.tar.gz rails-9a6fc9a540cd23af3ca061cb7406a6cdd5ad4294.tar.bz2 rails-9a6fc9a540cd23af3ca061cb7406a6cdd5ad4294.zip |
Don't force pluralization of controller name when defining a resource [#4980 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 10 | ||||
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 9 |
2 files changed, 18 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 67a629036b..0d22716ba7 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -443,7 +443,7 @@ module ActionDispatch def initialize(entities, options = {}) @name = entities.to_s @path = options.delete(:path) || @name - @controller = options.delete(:controller) || @name.to_s.pluralize + @controller = (options.delete(:controller) || @name).to_s @as = options.delete(:as) @options = options end @@ -547,6 +547,14 @@ module ActionDispatch [:show, :create, :update, :destroy, :new, :edit] end + def initialize(entities, options) + @name = entities.to_s + @path = options.delete(:path) || @name + @controller = (options.delete(:controller) || @name.to_s.pluralize).to_s + @as = options.delete(:as) + @options = options + end + def member_name name end diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 68e3dd6de3..8881838aef 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -318,6 +318,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end + resources :content + match '/:locale/*file.:format', :to => 'files#show', :file => /path\/to\/existing\/file/ end end @@ -1457,6 +1459,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end + def test_resources_controller_name_is_not_pluralized + with_test_routes do + get '/content' + assert_equal 'content#index', @response.body + end + end + private def with_test_routes yield |