mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Refactored create_migration on model generator.
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
parent
3545d6b0b2
commit
1ea7a00bc4
2 changed files with 3 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue