instance method
encrypted
Ruby on Rails 8.0.4
Since v5.2.8.1Signature
encrypted(path, key_path: "config/master.key", env_key: "RAILS_MASTER_KEY")
Returns an ActiveSupport::EncryptedConfiguration instance for an encrypted file. By default, the encryption key is taken from either ENV["RAILS_MASTER_KEY"], or from the config/master.key file.
my_config = Rails.application.encrypted("config/my_config.enc")
my_config.read
# => "foo:\n bar: 123\n"
my_config.foo.bar
# => 123
Encrypted files can be edited with the bin/rails encrypted:edit command. (See the output of bin/rails encrypted:edit --help for more information.)
Parameters
-
pathreq -
key_pathkey = "config/master.key" -
env_keykey = "RAILS_MASTER_KEY"
Source
# File railties/lib/rails/application.rb, line 518
def encrypted(path, key_path: "config/master.key", env_key: "RAILS_MASTER_KEY")
ActiveSupport::EncryptedConfiguration.new(
config_path: Rails.root.join(path),
key_path: Rails.root.join(key_path),
env_key: env_key,
raise_if_missing_key: config.require_master_key
)
end
Defined in railties/lib/rails/application.rb line 518
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Rails::Application