Class: Rails::Generators::EncryptedFileGenerator

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

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Base

base_root, class_option, default_source_root, desc, exit_on_failure?, hide!, hook_for, inherited, namespace, remove_hook_for, source_root

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
# File 'railties/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)
    setup = { content_path: file_path, key_path: key_path, env_key: "RAILS_MASTER_KEY", raise_if_missing_key: true }
    ActiveSupport::EncryptedFile.new(setup).write(template)
  end
end