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:
dog: poodle husky "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:
config=YAML.load_file('dog.yml') 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.