database.yml question

I'm working on my first RoR app and have run into an issue with database.yml. Originally I had two schemas defined in this file. Now I need to add a third schema and RoR is not recognizing that it's been added.

I've stopped and restarted the server (WeBrick), cleared my browser cache, and verified that there are no tabs in database.yml.

How can I get RoR to see the third schema has been added? Any help would be appreciated!

Thanks, Linda

development_db1:   adapter: mysql   database: db1_development   username: root   password:   host: localhost

development:   adapter: mysql   database: db_development   username: root   password:   host: localhost

development_db2:   adapter: mysql   database: db2_development   username: root   password:   host: localhost

what do you mean, saying "schema", why do you need three development databases and why use webrick, when mongrel exists? maybe a bit of reading on "rails environment" will help you more, than anything else...

Ruby and rails are enjoyable, that's why this programming has been rockin'

Linda, has you read the following links to answer your problem?

http://wiki.rubyonrails.org/rails/pages/HowtoUseMultipleDatabases

http://wiki.rubyonrails.org/rails/pages/HowtoUseMultipleDatabasesWithFixtures

I prefer to read some articles in search engine (ex:google) before playing in forum.

Good Luck,

Snipped some stuff for brevity...

Linda Metcalfe wrote:

How can I get RoR to see the third schema has been added? Any help would be appreciated!

From my database.yml...It's not recognizing development_db2 is there.

development_db1: adapter: mysql database: db1_development username: root password: host: localhost

development_db2:   adapter: mysql   database: db2_development   username: root   password:   host: localhost

(First although its' not WRONG what you have here, switch the naming convention to 'name'_'environment'. That just seems to be the norm.)

Ex:

db2_development:   adapter: mysql   etc etc etc.

Make sure you have a model class extending ActiveRecord::Base and have this class establish a connection (Using the attributes defined in your .yml config file automatically). Like so...

class Db1Base < ActiveRecord::Base   # Prevents Single Table Inheritance from being 'assumed'   self.abstract_class = true

  # Ties all extending models to this definition section in the database.yml   establish_connection "db1_#{RAILS_ENV}" end

class Db2Base < ActiveRecord::Base   # Prevents Single Table Inheritance from being 'assumed'   self.abstract_class = true

  # Ties all extending models to this definition section in the database.yml   establish_connection "db2_#{RAILS_ENV}" end

Now have all classes needing this DB extend the new Db1/2Base classes

Class SomeClassUsingTheDb1Definition < Db1Base   # This would connect to the DB1 database. end

Class SomeClassUsingTheDb2Definition < Db2Base   # This would connect to the DB2 database. end

You could put the establish_connection in each Model class directly, but using a base class to extend from keeps the created connections to a minimum in your connection pool.

Hope this helps.

P.S. Thanks to Obie Fernandez (The Rails Way), Rails Docs and PragDave for the info. (I had to read those sources a couple of times myself before I 'got it' the first time.