Class: DynamicFieldsets::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
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

Author:

  • Jeremiah Hemphill

Class Method Summary collapse

Instance Method Summary collapse

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.timestamped_migrations
    [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_fileObject

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_migrationObject

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