diff options
author | Timothy N. Tsvetkov <timothy.tsvetkov@gmail.com> | 2011-02-08 04:26:42 +0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-02-16 15:09:06 -0200 |
commit | c6fac7b449ad88a623d99487d2731dddc6555636 (patch) | |
tree | 9abd5868d39ca62bd999a70b1863dda7d837ca3b /railties | |
parent | 1754bd9b208e8d9207c226d1ffb3cee490856a78 (diff) | |
download | rails-c6fac7b449ad88a623d99487d2731dddc6555636.tar.gz rails-c6fac7b449ad88a623d99487d2731dddc6555636.tar.bz2 rails-c6fac7b449ad88a623d99487d2731dddc6555636.zip |
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>
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/generators/named_base.rb | 4 | ||||
-rw-r--r-- | railties/test/generators/named_base_test.rb | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 44a2639488..2af7f85463 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -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 diff --git a/railties/test/generators/named_base_test.rb b/railties/test/generators/named_base_test.rb index 1badae0713..f23701e99e 100644 --- a/railties/test/generators/named_base_test.rb +++ b/railties/test/generators/named_base_test.rb @@ -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 |