Rails配置密钥库返回nil [英] Rails configuration secret key base returning nil
本文介绍了Rails配置密钥库返回nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
运行rails控制台时,我在开发环境中对 Rails.configuration.secret_key_base
的调用一直返回nil。
#secrets.yml
开发:
secret_key_base:the-long-secret-由rake-secret生成
#...其他配置,运行时的调用heroku rails c在生产中也返回nil
这怎么可能? Running rails 4.1.0
解决方案
如文档:
lockquote
添加到这个文件的秘密是可通过 Rails.application.secrets
。
运行来自控制台的Rails.application.secrets.secret_key_base
应该返回:由-rke-secret生成的长密钥
When running rails console, my call to Rails.configuration.secret_key_base
in my development environment keeps returning nil.
#secrets.yml
development:
secret_key_base: the-long-secret-generated-by-rake-secret
#...other configs, a call while running heroku rails c in production also returns nil
How can this be? Running rails 4.1.0
解决方案
As noted in the documentation:
The secrets added to this file are accessible via
Rails.application.secrets
.
Running Rails.application.secrets.secret_key_base
from the console should return: the-long-secret-generated-by-rake-secret
这篇关于Rails配置密钥库返回nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文