Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@tukan tukan authored spastorino committed
View
4 railties/lib/rails/generators/named_base.rb
@@ -118,11 +118,11 @@ def index_helper
end
def singular_table_name
- @singular_table_name ||= table_name.singularize
+ @singular_table_name ||= (pluralize_table_names? ? table_name.singularize : table_name)
end
def plural_table_name
- @plural_table_name ||= table_name.pluralize
+ @plural_table_name ||= (pluralize_table_names? ? table_name : table_name.pluralize)
end
def plural_file_name
View
5 railties/test/generators/named_base_test.rb
@@ -98,6 +98,11 @@ def test_index_helper
assert_name g, 'posts', :index_helper
end
+ def test_index_helper_to_pluralize_once
+ g = generator ['Stadium']
+ assert_name g, 'stadia', :index_helper
+ end
+
def test_index_helper_with_uncountable
g = generator ['Sheep']
assert_name g, 'sheep_index', :index_helper
Please sign in to comment.
Something went wrong with that request. Please try again.