What do the &,<<, * mean in this database.yml file?

&default means you're labeling this set of attributes with some name for later use

<<: *default means you're including all attributes from group labeled as default


These represent node references (*) and associative array merges (<<) that refer to a node labeled with an anchor (&) tag -- wikipedia

Try it out yourself online.


The & marks an alias for the node (in your example &default aliases the development node as "default") and the * references the aliased node with the name "default". The <<: inserts the content of that node.

Allow me to quote the YAML spec here:

Repeated nodes (objects) are first identified by an anchor (marked with the ampersand - “&”), and are then aliased (referenced with an asterisk - “*”) thereafter.

So parts of your example

development: &default
  adapter: postgresql
  database: dev_development

test: &test
  <<: *default
  database: test_test

actually expand to

development: &default
  adapter: postgresql
  database: dev_development

test: &test
  adapter: postgresql       # from the "default" alias
  database: test_test       # overridden by the duplicate key

and at the same time make the "test" node as well available under the alias "test".

Have a look at the YAML specification - 2.2 Structures for further details (or if you need even moar docs++: 3.2.2.2. Anchors and Aliases)