mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Refactored create_migration on model generator.
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user