views:

275

answers:

1

I am writing an app that has different parts running on multiple servers. As a result, I have a ruby file filled with global values, which contain the IP addresses of the machines on which each part is running.

The app has a Rails front end that connects to a remote database (on one of the other servers). Is it possible to make use of the ruby global variable for the sql server IP inside the database.yml file?

If it's not possible to use the ruby global in the yml file, I'm open to other suggestions for better ways to achieve what I'm trying to do (xml or something similar) - the Ruby file was only for simplicity.

Thanks in Advance

A: 

I believe that you can use ERB inside of your database.yml file.

# database.yml
<% load('path/to/globals.rb') %>
development:
  host: <%= GLOBAL_CONFIG["development_sql"] %>
  ...

However I have yet to try this.

ryanb
Using <% load('/path/to/globals.rb') %> and host: <%= $GLOBAL_CONSTANT %> worked!Thanks, ryanb
Dave McClelland