Class: Strongbolt::Generators::InstallGenerator

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

Instance Method Summary collapse

Methods included from Migration

included

Instance Method Details

#copy_initializerObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/strongbolt/install_generator.rb', line 14

def copy_initializer
  # Laods all the application models
  Rails.application.eager_load!
  # Copy the file
  copy_file 'strongbolt.rb', 'config/initializers/strongbolt.rb'
  # Fill in the list of models of the application
  gsub_file 'config/initializers/strongbolt.rb', '%MODELS%',
            ActiveRecord::Base.descendants
                              .reject { |m| m.name =~ /^Strongbolt::/ }
                              .map    { |m| "'#{m.name}'" }
                              .join(', ')
end

#copy_migrationsObject



10
11
12
# File 'lib/generators/strongbolt/install_generator.rb', line 10

def copy_migrations
  copy_migration 'migration', 'create_strongbolt_tables'
end