views:

19

answers:

1

Lets say my file lives in the config folder and it's called config/foo.yml. I want to write in that file something like this:

development:
  status: developing
  foo: dev-bar

production:
  status: on-air
  foo: prod-bar

And then, I want my plugin to read this file and take the correct configuration values according to the environment the app is running in that very time.

What is the best way to achieve this?

A: 

Use YAML#load_file:

options = YAML.load_file('options.yml')
#=> { :development => { :status => 'developing', :foo => 'dev-bar' }, :production => { ... } 
neutrino
But how can I know what environment is being used in running time?
Erik Escobedo
use `Rails.env` (the newer version of `RAILS_ENV`)
neutrino
Oh... thank you.
Erik Escobedo