Why is Ruby on Rails secrets.yml not loading?

谁说我不能喝 提交于 2019-11-29 11:04:57

问题


I am trying to access my secret keys from the config/secrets.yml file.

secrets.yml:

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

Rails Console:

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

Where is my other_secret?!


回答1:


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. then run rails c again. (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. 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



来源:https://stackoverflow.com/questions/26310407/why-is-ruby-on-rails-secrets-yml-not-loading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!