Not sure about you, but when setting up a rails project, I get tired of
specifying username, login, etc 3 times, when it should only be done
once, in the config/database.yml file.
To me, it makes more sense to use yaml and do the following:
login: &login
adapter: mysql
encoding: utf8
username: robert
password: super_secret
The syntax is too obscure and not many people know it. It could
confuse people who use Rails for the first time, or people who are not
intimately familiar with YAML. I think it's more important that the
config file is easy to read, than saving 20 seconds at the beginning
of a project.
How about keeping the structure I suggested, but adding comments
explaining the structure for clarification? To me it makes sense
because it DRY's up your code, something Rails advocates, but doesn't
follow in this area.
I rarely use the same username and password for my production and
development databases, so not only does this obfuscate the file a
little bit it also makes me have to do more work when I get ready to
do production testing and deployment.
I totally disagree with the "perlism" comparison here. If it is a
taste thing, that's understandable, but saying the above code snippet
is too hard to read or akin to perlism, I don't agree. But whatever
the consensus is, is cool with me.
Second. I actually use Robert's syntax myself, as I'm sure many developers
do, but it would be too daunting for a first-time configuration.
Now, if there were a way to specify "default:" at the top, and have the
*code* that reads database.yml merge in the default hash keys, that would
be more worthwhile. But -1 for the pure-YAML version.