From 0d676ad311deb471b683e081c848022e87623374 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sat, 26 Jun 2010 08:15:33 +0100 Subject: [PATCH] Don't force pluralization of controller name when defining a resource --- actionpack/lib/action_dispatch/routing/mapper.rb | 10 +++++++++- 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 67a6290..0d22716 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 68e3dd6..8881838 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 -- 1.7.1