yaml中的简化写法

定义database.yml可能是一个比较繁琐的事,不过yaml有一种比较好的写法。


common: &common
adapter: mysql
encoding: utf8
username: root
password:
host: localhost

development:
database: whereisit_dev
<<: *common

production.
test:
database: whereisit_test
<<: *common

production:
database: whereisit_dev
<<: *common


用&定一个锚点,*引用它。

另外,yaml的冒号后面要加上空格