views:

74

answers:

2

I want to include a hash and list inside a YAML file that I'm parsing with the following command:

APP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")

My YAML file looks like this:

feeds: [{:url => 'http://www.google.com', :label => 'default'}]

But this doesn't seem to work. How would I go about achieving such a thing?

Thanks, Yuval


EDIT: Sorry, guys. I'm still unclear about how to do this and I suspect it is in part due to my somewhat vague phrasing. I asked a better-phrased, more broad question here. Thank you!

A: 
puts YAML::dump({:see => :this, :dumped => :object, :or => %w| read the manual at http://ruby-doc.org/core/classes/YAML.html|})


--- 
:dumped: :object
:or: 
- read
- the
- manual
- at
- http://ruby-doc.org/core/classes/YAML.html
:see: :this
+2  A: 

You can mark it up like this

feeds:
 - 
  url: 'http://www.google.com'
  label: 'default'

Note the spacing is important here. "-" must be indented by a single space (not a tab), and followed by a single space. And url & label must be indented by two spaces (not tabs either).

Additionally this might be helpful: http://www.yaml.org/YAML_for_ruby.html

Ceilingfish