How to include a YAML file inside a YAML file in Ruby

后端 未结 7 1444
悲&欢浪女
悲&欢浪女 2020-12-28 16:13

Is there a custom tag in YAML for ruby to include a YAML file inside a YAML file?

#E.g.:  
--- !include
filename: another.yml

A similar que

7条回答
  •  天命终不由人
    2020-12-28 16:49

    If your aim is avoiding duplication in your YAML file, not necessarily including external file, I recommend doing something like this:

    development: &default
      adapter: mysql
      encoding: utf8
      reconnect: false
      database: db_dev
      pool: 5
      username: usr
      password: psw
      host: localhost
      port: 3306
    
    dev_cache:
      <<: *default
    
    new:
      <<: *default
      database: db_new
    
    test:
      <<: *default
      database: db_test
    

提交回复
热议问题