2011-12-19 2 views
1

우리는 연락처 API 키 등 ...YML 파일이 다른 YML 파일에 액세스 할 수 있습니까?

내 YML 파일의 또 다른 하나는 config.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) 
관련 문제