我的 config.yml 文件看起来像这样
development: &development
<<: *development
sub1:
sub11: "myemail@fiverr.com"
sub12: "http://localhost"
staging:
<<: *development
sub1:
sub12: "http://google.com"
production:
<<: *development
sub1:
sub12: "http://youtube.com"
我像这样加载它
SETTINGS = YAML::load(File.open( "#{ROOT}/config/config.yml")).with_indifferent_access[ENV['RACK_ENV']] unless defined?(SETTINGS)
问题是在开发环境中:
SETTINGS[:sub1][:sub12] = "http://localhost"
SETTINGS[:sub1][:sub11] = "myemail@fiverr.com"
并在登台环境中:
SETTINGS[:sub1][:sub12] = "http://google.com"
SETTINGS[:sub1][:sub11] = "nil"
好像我不定义它就没了!