ruby-on-railsyamlenv

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


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???)

Solution

  • use following:-

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