Question

I have added some secrets to the new secrets.yml file in 4.1. According to the release notes, the new secrets are accessed via Rails.application.secrets.some_secret. In rails console, this works. However, at runtime these values are not available. I have tried putting the secrets in each environment and outside environments entirely.

secrets.yml
development: secret_key_base: secret_key some_secret: a_secret

rails console
R2.1.2 :001 > Rails.application.secrets => {:secret_key_base=>"secret_key", :some_secret=>"a_secret"}

a controller method
puts "secret #{Rails.application.secrets.some_secret}" "secret "

What am I missing?

Was it helpful?

Solution

Make sure you have restarted your server after modifying the secrets.yml file. Anything in config (excepting locale files) are only loaded once, at server start - modifying anything will require a server restart.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top