Hash inside YAML file?

后端 未结 3 1818
失恋的感觉
失恋的感觉 2020-12-30 21:41

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.         


        
3条回答
  •  生来不讨喜
    2020-12-30 22:21

    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

提交回复
热议问题