开发者

YAML Ruby 1.9.2: Stop adding Syck::MergeKey objects into my hashes

开发者 https://www.devze.com 2023-02-05 07:59 出处:网络
I am using Ruby 1.9.2 and Rails 3.0.1 and I am getting a weird issues with YAML. Here is my YAML file:

I am using Ruby 1.9.2 and Rails 3.0.1 and I am getting a weird issues with YAML. Here is my YAML file:

#config/tags_constants.yml
:main_ingredients: &ingredients
  - Beans 
  - Beef 
  - Cheese 
  - Chocolate 
  - Dairy 
  - Eggs 
  - Fish 
  - Fruits 
  - Game 
  - Lamb 
  - Nuts 
  - Pasta 
  - Pork 
  - Poultry 
  - Rice/Grains 
  - Shellfish 
  - Tofu/Soy 
  - Vegetables 

:excluded_ingredients:
<<: *ingredients

Here is what I am seeing in the console:

> hash = YAML.load(File.open("config/tags_constants.yml"))
> hash["excluded_ingredients"]
 => {开发者_如何学Go#<Syck::MergeKey:0x00000101b379d0>=>["Beans", "Beef", "Cheese", "Chocolate", "Dairy", "Eggs", "Fish", "Fruits", "Game", "Lamb", "Nuts", "Pasta", "Pork", "Poultry", "Rice/Grains", "Shellfish", "Tofu/Soy"]} 

How do I get YAML to merge the values without adding these weird Syck::MergeKey objects?


Try the following:

client: &client
  - Brad
  - Angelina
:development: 
  :requests: 1
  :client: 
    :session: "something"
    :paths: 
      *client
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号