I’m trying to DRY up my database.yml file.
At first I tried settign some variables in my environment.rb to use in
the database.yml, but it doesnt seem that the environment.rb variables
are available to the Erb that gets run on the database.yml (at least not
So now I am trying to use an alias to name my databases, but there is
really REALLY bad documentation on aliases/anchors in YAML, at lease if
you google it. And whatever I did figure out doesn’t seem to work.
So I want to replace *app in the following with the folder name for the
rails app. Ie. say I did ‘rails newapp’, I would want my databases to
be named newapp_dev, newapp_test, and newapp_prod. But I dont want to
have to change it in 3 places in the database.yml. I don;t want to
change it all in the database yml, but it seems that the alternative
would be to put a bunch of ENV variables on the commandline (ie. the
ones in environment.rb dont work).
Here is my database.yml:
So I want to have ‘*app’ replaced with ‘newapp’.
- &app “fanatics”
app: - &app “fanatics”
app: &app “fanatics”
to set my alias, but none of these seem to work.
What am I doing wrong? Is the an intelligable reference for yaml that
shows how to use anchors this way?