How to read YAML file
July 7, 2008 – 1:47 pmThis is code that i just implement into my rails code. Actually this is how to read data in YAML file and implement it into rails code.
1. Create your yaml file in config/yourfilename.yml.
Example : let say we want read username and password from yaml file below.

2. How to load yaml file from rails?…put
APP_CONFIG = YAML.load_file(”#{RAILS_ROOT}/config/yourfilename.yml”)
into development.rb or production.rb on config folder.
3. How to call?…
username == APP_CONFIG['username'] && password == APP_CONFIG['password']
Give a try…
Popularity: 21% [?]













