在 Rails 中设置环境变量
我正在尝试使我的项目成为 OSS,并且我想从配置中删除所有敏感信息。我正在尝试使用 ENV['DB_PASS'] = mypassword
。我在哪里设置这个?我已经在 .bashrc 文件中尝试过 export DB_PASS=mypassword
。但这是行不通的。
I'm trying to make my project OSS, and I'd like to remove any sensitive info from the configs. I'm trying to have ENV['DB_PASS'] = mypassword
. Where would I set this? I've tried export DB_PASS=mypassword
in my .bashrc file. But that's not working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定
导出
不起作用吗?您是否尝试过echo $DB_PASS
? (此外,对 .bashrc 的更改直到您下次登录时才会生效。)处理此问题的更常见方法是创建一个不在存储库中跟踪的单独配置文件,然后提供
config.sample
文件演示了常见的配置选项,但带有虚拟值。Are you sure
export
isn't working? Have you triedecho $DB_PASS
? (Also, changes to .bashrc won't take effect until the next time you log in.)A more common way to handle this problem is to create a separate config file that is not tracked in your repository, and then provide a
config.sample
file demonstrating the common configuration options but with dummy values.