diff options
author | José Valim <jose.valim@gmail.com> | 2009-08-09 12:01:40 +0200 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-08-09 15:57:59 +0100 |
commit | 1ea7a00bc4c2d28abb21a36ee09f44f5210b06f6 (patch) | |
tree | 334b7c9ad1c56978a6682477749f7b347b98dcd4 | |
parent | 3545d6b0b227cc9ee4a645097bdbd43b33b42a87 (diff) | |
download | rails-1ea7a00bc4c2d28abb21a36ee09f44f5210b06f6.tar.gz rails-1ea7a00bc4c2d28abb21a36ee09f44f5210b06f6.tar.bz2 rails-1ea7a00bc4c2d28abb21a36ee09f44f5210b06f6.zip |
Refactored create_migration on model generator.
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
-rw-r--r-- | railties/lib/generators/active_record/model/model_generator.rb | 8 | ||||
-rw-r--r-- | railties/lib/generators/named_base.rb | 2 |
2 files changed, 3 insertions, 7 deletions
diff --git a/railties/lib/generators/active_record/model/model_generator.rb b/railties/lib/generators/active_record/model/model_generator.rb index 5c6033629f..2641083e0d 100644 --- a/railties/lib/generators/active_record/model/model_generator.rb +++ b/railties/lib/generators/active_record/model/model_generator.rb @@ -12,12 +12,8 @@ module ActiveRecord class_option :parent, :type => :string, :desc => "The parent class for the generated model" def create_migration_file - if options[:migration] && options[:parent].nil? - 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 + return unless options[:migration] && options[:parent].nil? + migration_template "migration.rb", "db/migrate/create_#{table_name}.rb" end def create_model_file diff --git a/railties/lib/generators/named_base.rb b/railties/lib/generators/named_base.rb index c2b958e311..cd7aa61b50 100644 --- a/railties/lib/generators/named_base.rb +++ b/railties/lib/generators/named_base.rb @@ -36,7 +36,7 @@ module Rails @class_name = "#{class_nesting}::#{class_name_without_nesting}" end - @table_name.gsub! '/', '_' + @table_name.gsub!('/', '_') end # Convert attributes hash into an array with GeneratedAttribute objects. |