Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Peter Cooperx http://www.petercooper.co.uk/

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

App level configuration for your Rails apps

Hard coding stuff into your view templates isn't a great idea, and sometimes you want it out of your layouts too. If you have variables your app requires, but which may change between deployments, put them in /config/appconfig.yml in YAML format, then put this at the top of your /config/environment.rb:

   1  require 'yaml'


And at the bottom of your /config/environment.rb:

   1  APP_CONFIG = YAML::load(File.open("#{RAILS_ROOT}/config/appconfig.yml"))


Now your YAML variables are accessible anywhere from your controllers or views like so:

   1  APP_CONFIG["variable"]


Easy peasy.
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS