Class: Resort::Generators::MigrationGenerator
- Inherits:
-
ActiveRecord::Generators::Base
- Object
- ActiveRecord::Generators::Base
- Resort::Generators::MigrationGenerator
- Defined in:
- lib/generators/active_record/resort_generator.rb
Overview
Rails generator to add a migration for Resort
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for ‘Rails::Generators::Migration`.
Instance Method Summary collapse
-
#copy_migration_file ⇒ Object
Copies a migration file adding resort fields to a given model.
Class Method Details
.next_migration_number(dirname) ⇒ Object
Implement the required interface for ‘Rails::Generators::Migration`. Taken from `ActiveRecord` code.
13 14 15 16 17 18 19 |
# File 'lib/generators/active_record/resort_generator.rb', line 13 def self.next_migration_number(dirname) if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#copy_migration_file ⇒ Object
Copies a migration file adding resort fields to a given model
25 26 27 |
# File 'lib/generators/active_record/resort_generator.rb', line 25 def copy_migration_file migration_template 'migration.rb', "db/migrate/add_resort_fields_to_#{table_name.pluralize}.rb" end |