2

We have a site wide config.yml file which contacts api keys etc...

Can another one of my YML files access a value in the config.yml?

config.yml:

development:
    thing: 123123123123

plugin_config.yml:

development:
    thing: config.yml.development.thing

is this possible?

j0k
  • 22,600
  • 28
  • 79
  • 90
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
  • possible duplicate of [How to include a YAML file inside a YAML file?](http://stackoverflow.com/questions/2278241/how-to-include-a-yaml-file-inside-a-yaml-file) – Dave Newton Dec 19 '11 at 23:25

1 Answers1

7

You can always parse it with ERB:

development:
    thing: 123123123123

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

Then load the first one and also parse it with ERB (in an initializer or something):

CONFIG = YAML.load(ERB.new(File.read(Rails.root.join('config','plugin_config.yml'))).result)
Unixmonkey
  • 18,485
  • 7
  • 55
  • 78