edge badge
Methods
A
Instance Public methods
add_encrypted_file(file_path, key_path)
# File railties/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb, line 8
def add_encrypted_file(file_path, key_path)
  unless File.exist?(file_path)
    say "Adding #{file_path} to store encrypted content."
    say ""
    say "The following content has been encrypted with the encryption key:"
    say ""
    say template, :on_green
    say ""

    add_encrypted_file_silently(file_path, key_path)

    say "You can edit encrypted file with `bin/rails encrypted:edit #{file_path}`."
    say ""
  end
end
add_encrypted_file_silently(file_path, key_path, template = encrypted_file_template)
# File railties/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb, line 24
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" }
    ActiveSupport::EncryptedFile.new(setup).write(template)
  end
end