简体   繁体   English

如何在不重新启动Rails服务器的情况下重新加载secrets.yml?

[英]How to reload secrets.yml without restart rails server?

How to reload secrets.yml without restart rails server, like if I manually update secrets.yml credentials on updating it will auto load to the rails application 如何在不重新启动Rails服务器的情况下重新加载secrets.yml,例如如果我在更新时手动更新secrets.yml凭据,它将自动加载到rails应用程序

eg in secrets.yml 例如在secrets.yml中

   api_key: 1111111111

In the application, I can access using 在应用程序中,我可以使用

   puts Rails.application.secrets.api_key
   => '1111111111'

for example, if I manually update secrets.yml file 例如,如果我手动更新secrets.yml文件

   api_key: 222222222

In the application, the result should have to be this 在应用程序中,结果应为

   puts Rails.application.secrets.api_key
   => '222222222'

Without restarting server 无需重启服务器

You should be able to add a line to your config/spring.rb: 您应该能够在config / spring.rb中添加一行:

Spring.watch "config/secrets.yml"

This will allow Spring to detect when changes have occurred in your secrets.yml file. 这将使Spring能够检测secrets.yml文件中的更改时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM