database.yml host read from yml

I have a yml file with ip info. When I try to do " host: Site['name']
['ip'] it is getting interpreted directly and it is saying Bad URI:
Site['name']['ip']

How do I get the database yml to interpret the Site constant? I can
see the hash in the console.

anyone?

database.yml is passed through erb

Fred

Ok, in my load_config I do this:

Site = YAML.load_file(File.join(RAILS_ROOT, ‘config’, ‘sites.yml’))

Something like this in the database.yml?

host: <%= Site[‘name’][‘db’] %>

YAML.load(ERB.new(File.read(path_to_file)).result)

Is this correct?

<% Site = YAML.load(ERB.new(File.read(File.join(RAILS_ROOT, ‘config’, ‘sites.yml’))).result) %>