Custom Search

How to read YAML file

July 7, 2008 – 1:47 pm

This 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…

Zemanta Pixie

Popularity: 21% [?]

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • StumbleUpon
  • Technorati
  • TwitThis
  • E-mail this story to a friend!
  • Print this article!

Tags: , ,


Related Posts

Post a Comment