Showing posts with label Ruby. Show all posts
Showing posts with label Ruby. Show all posts

Monday, April 22, 2013

Load hash from YAML with keys as symbols in Ruby

The most easy way is to start keys with colon ':'

:db:
  - :host: db.host.com
    :port: 5210

Now when you load this

db_config = YAML::load(File.open(File.expand_path('../config/database.yml', File.dirname(__FILE__))))

it will be "symbolized"