In the environment.rb file I replaced
ActiveRecord::Base.configurations
File.open("#{RAILS_ROOT}/config/database.yml") { |f| YAML::load(f) }
with
ActiveRecord::Base.configurations
YAML::load(ERB.new((IO.read("#{RAILS_ROOT}/config/
database.yml"))).result)
and added
SITE = ENV[''site'']
so that I could do this in my database.yml file:
development:
   adapter: mysql
   database: <%= SITE %>_dev
   host: localhost
   username: root
   password:
test:
   adapter: mysql
   database: <%= SITE %>_test
   host: localhost
   username: root
   password:
production:
   adapter: mysql
   database: <%= SITE %>
   host: localhost
   username: root
   password:
Now, I can set the database that my application will use dynamically  
from the environment.  This is particularly useful if you plan on  
"reusing" your application code base for several clients, each with  
their own database.
Duane Johnson
(canadaduane)
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails