Tag Archives: yml

Could Not Parse Yaml, Why!?

Yaml config files are a great way to store static data in your rails application. But there’s a little caveat I experienced today. Observe the following yaml file:

  "golden retriever"

Looks fine, right? Now let’s assume you’ve named this yaml file dog.yml and it lives in your application’s config directory. You’d figure you could access the data by doing something like the following:

puts config (yields the hash {"dog" => { "poodle", "husky", "golden retriever" } }

But for whatever reason, you are getting an error (couldn’t parse YAML at line x column x). You suspected that “golden retriever” might be a problem due to the space, but you’ve already quoted it, so no, it can’t be the problem.

Continue reading