Class: Legate::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/legate/generators/legate/install_generator.rb

Overview

‘rails generate legate:install` — creates the migration for the ActiveRecord session store and an initializer that wires it up.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Rails requires generators that create migrations to provide the next migration number; mirror ActiveRecord’s own implementation.



20
21
22
23
# File 'lib/legate/generators/legate/install_generator.rb', line 20

def self.next_migration_number(dirname)
  next_num = current_migration_number(dirname) + 1
  ::ActiveRecord::Migration.next_migration_number(next_num)
end

Instance Method Details

#create_initializer_fileObject



30
31
32
# File 'lib/legate/generators/legate/install_generator.rb', line 30

def create_initializer_file
  template 'initializer.rb', 'config/initializers/legate.rb'
end

#create_migration_fileObject



25
26
27
28
# File 'lib/legate/generators/legate/install_generator.rb', line 25

def create_migration_file
  migration_template 'create_legate_tables.rb.tt',
                     'db/migrate/create_legate_tables.rb'
end