diff options
author | Hugo Peixoto <hugo.peixoto@gmail.com> | 2009-08-09 11:24:40 +0100 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-08-09 02:38:35 -0700 |
commit | 22b38c18c61a18babd671b973e804e054ba795d4 (patch) | |
tree | 85c88c2f314a33cdb2cbf46c52fccbe6cb5f23dd /railties/lib/generators | |
parent | a0caad5255ed120192755fce10960a38b53c056d (diff) | |
download | rails-22b38c18c61a18babd671b973e804e054ba795d4.tar.gz rails-22b38c18c61a18babd671b973e804e054ba795d4.tar.bz2 rails-22b38c18c61a18babd671b973e804e054ba795d4.zip |
Fixed generating a namespaced model with table pluralization turned off. Add tests for namespaced model generation.
[#767 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'railties/lib/generators')
-rw-r--r-- | railties/lib/generators/active_record/model/model_generator.rb | 4 | ||||
-rw-r--r-- | railties/lib/generators/named_base.rb | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/railties/lib/generators/active_record/model/model_generator.rb b/railties/lib/generators/active_record/model/model_generator.rb index 54187aede0..5c6033629f 100644 --- a/railties/lib/generators/active_record/model/model_generator.rb +++ b/railties/lib/generators/active_record/model/model_generator.rb @@ -13,7 +13,9 @@ module ActiveRecord def create_migration_file if options[:migration] && options[:parent].nil? - file_name = "create_#{file_path.gsub(/\//, '_').pluralize}" + klass_name = file_path.gsub(/\//, '_') + klass_name = klass_name.pluralize if ActiveRecord::Base.pluralize_table_names + file_name = "create_#{klass_name}" migration_template "migration.rb", "db/migrate/#{file_name}.rb" end end diff --git a/railties/lib/generators/named_base.rb b/railties/lib/generators/named_base.rb index 9632e6806c..c2b958e311 100644 --- a/railties/lib/generators/named_base.rb +++ b/railties/lib/generators/named_base.rb @@ -28,7 +28,6 @@ module Rails else singular_name end - @table_name.gsub! '/', '_' if class_nesting.empty? @class_name = class_name_without_nesting @@ -36,6 +35,8 @@ module Rails @table_name = class_nesting.underscore << "_" << @table_name @class_name = "#{class_nesting}::#{class_name_without_nesting}" end + + @table_name.gsub! '/', '_' end # Convert attributes hash into an array with GeneratedAttribute objects. |