Class: Rails::Generators::EncryptedFileGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Base

add_shebang_option!, banner, base_name, base_root, class_option, default_aliases_for_option, default_for_option, default_generator_root, default_source_root, default_value_for_option, desc, exit_on_failure?, generator_name, hide!, hook_for, hooks, inherited, namespace, prepare_for_invocation, remove_hook_for, source_root, usage_path

Methods included from Actions

#add_source, #environment, #gem, #gem_group, #generate, #git, #github, #initialize, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor

Instance Method Details

#add_encrypted_file_silently(file_path, key_path, template = encrypted_file_template) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb', line 9

def add_encrypted_file_silently(file_path, key_path, template = encrypted_file_template)
  unless File.exist?(file_path)
    ActiveSupport::EncryptedFile.new(
      content_path: file_path,
      key_path: key_path,
      env_key: "RAILS_MASTER_KEY",
      raise_if_missing_key: true
    ).write(template)
  end
end