instance method
secrets
Ruby on Rails 5.2.8.1
Since v4.1.16 Last seen in v7.1.6Signature
secrets()
Returns secrets added to config/secrets.yml.
Example:
development: secret_key_base: 836fa3665997a860728bcb9e9a1e704d427cfc920e79d847d79c8a9a907b9e965defa4154b2b86bdec6930adbe33f21364523a6f6ce363865724549fdfc08553 test: secret_key_base: 5a37811464e7d378488b0f073e2193b093682e4e21f5d6f3ae0a4e1781e61a351fdc878a843424e81c73fb484a40d23f92c8dafac4870e74ede6e5e174423010 production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> namespace: my_app_production
Rails.application.secrets.namespace returns my_app_production in the production environment.
Source
# File railties/lib/rails/application.rb, line 394
def secrets
@secrets ||= begin
secrets = ActiveSupport::OrderedOptions.new
files = config.paths["config/secrets"].existent
files = files.reject { |path| path.end_with?(".enc") } unless config.read_encrypted_secrets
secrets.merge! Rails::Secrets.parse(files, env: Rails.env)
# Fallback to config.secret_key_base if secrets.secret_key_base isn't set
secrets.secret_key_base ||= config.secret_key_base
# Fallback to config.secret_token if secrets.secret_token isn't set
secrets.secret_token ||= config.secret_token
if secrets.secret_token.present?
ActiveSupport::Deprecation.warn(
"`secrets.secret_token` is deprecated in favor of `secret_key_base` and will be removed in Rails 6.0."
)
end
secrets
end
end
Defined in railties/lib/rails/application.rb line 394
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Rails::Application