Class: Rcap::Generators::MigrationsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/rcap/migrations/migrations_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



13
14
15
# File 'lib/generators/rcap/migrations/migrations_generator.rb', line 13

def self.source_root
  @_rcap_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end

Instance Method Details

#create_migration_fileObject



17
18
19
20
21
22
23
# File 'lib/generators/rcap/migrations/migrations_generator.rb', line 17

def create_migration_file
  Dir[File.join(MigrationsGenerator.source_root, '*_migration.rb')].each do |file|
    model = file[/(.*\/)?(.*)_migration.rb/, 2]
    migration_template file, "db/migrate/create_#{model}_table.rb"
    Kernel::sleep 1
  end
end