Short form: What’s the best way to customize my environment so “rails
new …” uses a custom template rather than the default?
Long form: Every time I create a new Rails project, the first thing I do
is edit config/database.yml so the lines that previously read:
username: <%= ENV[‘MYSQL_USERID’] || “root” %>
password: <%= ENV[‘MYSQL_PASSWORD’] || “” %>
socket: <%= ENV[‘MYSQL_SOCKET’] || “/tmp/mysql.sock” %>
… that is, it picks up the values for username, password and socket
from environment variables I’ve set.
I could edit $RAILS/generators/…mysql.yml directly, but there are
two problems: first, it’s a bad idea to modify core files, and second,
it pre-expands the .yml code so my username and password are exposed in
the resulting file. Not what I want…
Another approach would be to write a rake task to post-facto modify the
file, but that seems a bit clunky.
WWDHD? (What would David Heinemeier do?)