Class: DynamicFieldsets::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- DynamicFieldsets::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/dynamic_fieldsets/install_generator.rb
Overview
Generator for copying the InProgressForm model migration and an initializer to the including project
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
Instance Method Summary collapse
-
#copy_config_file ⇒ Object
Creates the config file Mostly commented out until the config actually has information.
-
#copy_migration ⇒ Object
Creates the migration.
Class Method Details
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration. thanks Kaminari gem for this bit of code
23 24 25 26 27 28 29 30 |
# File 'lib/generators/dynamic_fieldsets/install_generator.rb', line 23 def self.next_migration_number(dirname) #:nodoc: next_migration_number = current_migration_number(dirname) + 1 if ActiveRecord::Base. [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max else "%.3d" % next_migration_number end end |
Instance Method Details
#copy_config_file ⇒ Object
Creates the config file Mostly commented out until the config actually has information
34 35 36 |
# File 'lib/generators/dynamic_fieldsets/install_generator.rb', line 34 def copy_config_file copy_file "config.rb", "config/initializers/dynamic_fieldsets.rb" end |
#copy_migration ⇒ Object
Creates the migration
39 40 41 |
# File 'lib/generators/dynamic_fieldsets/install_generator.rb', line 39 def copy_migration migration_template "migrations/install_migration.rb", "db/migrate/create_dynamic_fieldsets_tables.rb" end |