Class: ActiveRecord::Generators::ModelGenerator
- Inherits:
-
Base
- Object
- Base
- ActiveRecord::Generators::ModelGenerator
- Defined in:
- lib/modular_migration/active_record/generators/model_generator.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#create_migration_file ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/modular_migration/active_record/generators/model_generator.rb', line 8 def create_migration_file return unless [:migration] && [:parent].nil? attributes.each { |a| a..delete(:index) if a.reference? && !a.has_index? } if [:indexes] == false template_file = Rails.version.to_i < 4 ? 'migration.rb' : '../../migration/templates/create_table_migration.rb' migration_file = File.join(FileUtils.mkdir_p(File.join('db/migrate', class_path.join('/'), file_name)), "/create_#{table_name}.rb") migration_template template_file, migration_file end |