简体   繁体   English

为什么Ruby on Rails secretts.yml没有加载?

[英]Why is Ruby on Rails secrets.yml not loading?

I am trying to access my secret keys from the config/secrets.yml file. 我试图从config/secrets.yml文件中访问我的密钥。

secrets.yml: secrets.yml:

development:
  secret_key_base: laksjfla...alskdfjlaksjdflaksd
  other_secret: password

Rails Console: Rails控制台:

$ rails c
> Rails.application.secrets
> => {:secret_key_base=>"laksjfla...alskdfjlaksjdflaksd"}

Where is my other_secret ?! 我的other_secret在哪里?!

I've faced a similar problem once, try to reload spring server with bin/spring stop , so the changes to secrets.yml should take effect. 我曾遇到类似的问题,尝试用bin/spring stop重新加载spring服务器,所以对secrets.yml的更改应该生效。 then run rails c again. 然后再次运行rails c (posting comment as a answer). (发表评论作为答案)。

There is an open pull request here - https://github.com/rails/spring/pull/289 - spring does not watch for changes in secrets.yml by default. 这里有一个开放的拉取请求 - https://github.com/rails/spring/pull/289 - 默认情况下,spring不会监视secrets.yml的更改。 One of the comments says: 其中一条评论说:

new version of gem (spring) still wasn't released, so you can pull it from github or add Spring.watch "config/secrets.yml" to your config/spring.rb meanwhile 新版本的gem(spring)仍然没有发布,所以你可以从github中提取它或者将Spring.watch“config / secrets.yml”添加到你的config / spring.rb同时

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

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