Class: ActiveStorageEncryption::InstallGenerator

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

Overview

The generator is used to install ActiveStorageEncryption. It adds the ‘encryption_key` column to ActiveStorage::Blob. Run it with `bin/rails g active_storage_encryption:install` in your console.

Instance Method Summary collapse

Instance Method Details

#create_migration_fileObject

Generates monolithic migration file that contains all database changes.



16
17
18
19
20
21
22
23
# File 'lib/generators/install_generator.rb', line 16

def create_migration_file
  # Adding a new migration to the gem is then just adding a file.
  migration_file_paths_in_order = Dir.glob(__dir__ + "/*.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