Fixed issue #6363, avoid to pluralized already pluralized names and singularize 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>
This commit is contained in:
Timothy N. Tsvetkov
2011-02-08 04:26:42 +03:00
committed by Santiago Pastorino
parent 1754bd9b20
commit c6fac7b449
2 changed files with 7 additions and 2 deletions

View File

@@ -118,11 +118,11 @@ module Rails
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 File

@@ -98,6 +98,11 @@ class NamedBaseTest < Rails::Generators::TestCase
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