how to customize config/database.yml

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:

development:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: myapp_development
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

instead read:

development:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: myapp_development
  pool: 5
  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?)

- ff

Short form: What's the best way to customize my environment so "rails
new ..." uses a custom template rather than the default?

Sounds like you want rails' app templates ( there's a screencast at
http://railscasts.com/episodes/148-app-templates-in-rails-2-3 )

Fred

Frederick Cheung wrote: