Is there a way to specify a secret for all environments in secrets.yml from rails 4.1?

As in the question, is there a way to make a secret known for all three environments without copying and pasting in this way?

secrets.yml

development: secret_key_base: ... my_global_secret: foo test: secret_key_base: ... my_global_secret: foo production: secret_key_base: ... my_global_secret: foo 
+8
ruby-on-rails ruby-on-rails-4
source share
2 answers

You can define a common shared key and use it with &label and <<: *label

 common: &common secret_key_base: ... my_global_secret: foo development: <<: *common something_specific_to_development: ... test: <<: *common something_specific_to_test: ... production: <<: *common something_specific_to_production: ... 

Update: for Rails 5.1 +

Rails 5.1 adds the shared key, which is automatically applied to all environments:

 shared: # Everything nested under this key is automatically shared secret_key_base: ... my_global_secret: "foo" development: my_global_secret: "override value for dev" test: ... 
+22
source share

Using common: &common for me did not work with Rails 5.1 - shared: though.

+1
source share

All Articles