Class: ScatterGather::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ScatterGather::Generators::InstallGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/scatter_gather/install_generator.rb
Overview
The generator is used to install ScatterGather. It adds the migration that creates
the scatter_gather_completions table.
Run it with bin/rails g scatter_gather:install in your console.
Instance Method Summary collapse
-
#create_migration_file ⇒ Object
Generates migration file that creates the scatter_gather_completions table.
Instance Method Details
#create_migration_file ⇒ Object
Generates migration file that creates the scatter_gather_completions table.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/scatter_gather/install_generator.rb', line 17 def create_migration_file # Migration files are named "...migration_001.rb" etc. This allows them to be emitted # as they get added, and the order of the migrations can be controlled using predictable sorting. # Adding a new migration to the gem is then just adding a file. migration_file_paths_in_order = Dir.glob(__dir__ + "/*_migration_*.rb.erb").sort migration_file_paths_in_order.each do |migration_template_path| untemplated_migration_filename = File.basename(migration_template_path).gsub(/\.erb$/, "") migration_template(migration_template_path, File.join(db_migrate_path, untemplated_migration_filename)) end end |