2011-12-19 111 views
1

我们有一个网站广泛config.yml文件,联系人API密钥等..YML文件可以访问另一个YML文件吗?

可以在我的YML文件的另一个访问中config.yml值?

config.yml:

development: 
    thing: 123123123123 

plugin_config.yml:

development: 
    thing: config.yml.development.thing 

这可能吗?

+0

可能重复[如何在YAML文件中包含YAML文件?](http://stackoverflow.com/questions/2278241/how-to-include-a-yaml-file-inside-a-yaml-file) –

回答

6

您可以随时与ERB解析它:

development: 
    thing: 123123123123 

development: 
    thing: <%= YAML.load(ERB.new(File.read(Rails.root.join('config','config.yml'))).result)['development'] %> 

然后加载第一个,也ERB解析它(在初始化或东西):的

CONFIG = YAML.load(ERB.new(File.read(Rails.root.join('config','plugin_config.yml'))).result)