rails 3, how use an ENV config vars in a Settings.yml file?

jpw picture jpw · May 3, 2011 · Viewed 43.9k times · Source

In my settings.yml file I have several config vars, some of which reference ENV[] variables.

for example I have ENV['FOOVAR'] equals WIDGET

I thought I could reference ENV vars inside <% %> like this:

Settings.yml:

default:
   cv1: Foo
   cv2: <% ENV['FOOVAR'] %>

in rails console if I type

> ENV['FOOVAR']
=> WIDGET

but

> Settings.cv1
=> Foo   (works okay)
> Settings.cv2
=>nil   (doesn't work???)

Answer

Anubhaw picture Anubhaw · May 3, 2011

use following:-

 default:
       cv1: Foo
       cv2: <%= ENV['FOOVAR'] %>