read

Create a new initializer config/initializers/load_config.rb with that content:

APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env]

Then, create a configuration file under config/config.yml and put in your config properties:

development:
  my_propery: true

test:
  my_propery: true

production:
  my_propery: false

Now you can use the configuration via the APP_CONFIG constant everywhere in your ruby code:

if APP_CONFIG['my_propery']
  # your code here...
end
Blog Logo

Tom Raithel


Published

comments powered by Disqus
Image

frontcoded.com

A dumping ground for web development stuff

Back to Overview