Skip to content
This repository
Browse code

Fixed issue #6363, avoid to pluralized already pluralized names and s…

…ingularize a single in generators, for example stadia is a valid plural for stadium. But calling pluralize for stadia will return stadias which sematically is not corrent in this case

[#6363 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information...
commit c6fac7b449ad88a623d99487d2731dddc6555636 1 parent 1754bd9
Timothy N. Tsvetkov authored February 08, 2011 spastorino committed February 16, 2011
4  railties/lib/rails/generators/named_base.rb
@@ -118,11 +118,11 @@ def index_helper
118 118
         end
119 119
 
120 120
         def singular_table_name
121  
-          @singular_table_name ||= table_name.singularize
  121
+          @singular_table_name ||= (pluralize_table_names? ? table_name.singularize : table_name)
122 122
         end
123 123
 
124 124
         def plural_table_name
125  
-          @plural_table_name ||= table_name.pluralize
  125
+          @plural_table_name ||= (pluralize_table_names? ? table_name : table_name.pluralize)
126 126
         end
127 127
 
128 128
         def plural_file_name
5  railties/test/generators/named_base_test.rb
@@ -98,6 +98,11 @@ def test_index_helper
98 98
     assert_name g, 'posts', :index_helper
99 99
   end
100 100
 
  101
+  def test_index_helper_to_pluralize_once
  102
+    g = generator ['Stadium']
  103
+    assert_name g, 'stadia', :index_helper
  104
+  end
  105
+
101 106
   def test_index_helper_with_uncountable
102 107
     g = generator ['Sheep']
103 108
     assert_name g, 'sheep_index', :index_helper

0 notes on commit c6fac7b

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