就像问题所说的那样,有没有办法让所有3个环境都知道这个秘密,而不会像这样复制和粘贴?
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
答案 0 :(得分:26)
您可以使用&label
和<<: *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: ...
Rails 5.1添加了shared
密钥,该密钥自动应用于所有环境:
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:
...
答案 1 :(得分:1)
使用common: &common
对我来说对Rails 5.1不起作用 - shared:
但确实如此。