Class: RailsAuditLog::Generators::EncryptionGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_initializer_fileObject



14
15
16
17
# File 'lib/generators/rails_audit_log/encryption/encryption_generator.rb', line 14

def create_initializer_file
  template "rails_audit_log_encryption.rb",
           "config/initializers/rails_audit_log_encryption.rb"
end

#create_migration_fileObject



19
20
21
22
23
24
# File 'lib/generators/rails_audit_log/encryption/encryption_generator.rb', line 19

def create_migration_file
  migration_template(
    "encrypt_rails_audit_log_entries.rb",
    "db/migrate/encrypt_rails_audit_log_entries.rb"
  )
end


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/generators/rails_audit_log/encryption/encryption_generator.rb', line 26

def print_next_steps
  say ""
  say "Next steps:", :green
  say "  1. Run `bin/rails db:encryption:init` to generate encryption keys"
  say "     and store them in config/credentials.yml.enc."
  say "  2. Review config/initializers/rails_audit_log_encryption.rb and wire"
  say "     the generated keys into ActiveRecord::Encryption."
  say "  3. Add `audit_log encrypt: true` (or set RailsAuditLog.encrypt = true)"
  say "     on the models whose audit data you want to protect."
  say "  4. Edit the generated migration — add your encrypted model class names"
  say "     to ENCRYPTED_MODELS — then run `bin/rails db:migrate`."
  say ""
end