![](/img/trans.png)
[英]Rails - Mina - not able to load environment variables in database.yml file
[英]Load environment variables into the .railsrc file?
我正在尝试在.railsrc
文件中加载环境变量,
我在我的.bash_profile中定义了我的RAIL_UTILS_HOME
env var
export RAIL_UTILS_HOME='/Path/to/Rails/utils'
这是我在.railsrc
尝试加载默认的rails模板
-T -m $RAIL_UTILS_HOME/template.irb
但是我的$RAIL_UTILS_HOME
var没有被扩展,
知道如何正确地做到这一点?
您应该能够通过ENV["RAIL_UTILS_HOME"]
访问环境变量,因为它必须在.railsrc
文件中工作。
因为.railsrc
文件没有明确的模式,我假设你的.irbrc
文件中有这样的东西:
railsrc_path = File.expand_path('~/.railsrc')
if ( ENV['RAILS_ENV'] || defined? Rails ) && File.exist?( railsrc_path )
begin
load railsrc_path
rescue Exception
warn "Could not load: #{ railsrc_path }" # because of $!.message
end
end
这将在您启动rails控制台时加载~/.railsrc
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.