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

Darryl A. Ring http://www.hydra3.org/

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

Loading and parsing YAML files

I use YAML heavily to specify basic configuration options for my applications. Additionally, I have bash scripts to download and parse currency and weather information, which all gets stored as YAML for ease of use.

This is how I parse the YAML into my applications:

require 'yaml'

class ApplicationController < ActionController::Base
  before_filter :configure_app

  # Your code here...

  def configure_app
    @config = YAML::load(File.open("#{RAILS_ROOT}/config/config.yml"))
  end
end
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS