There exists a couple of Rails 3 internet sites that require to gain access to a typical database for order monitoring and fulfillment.

Essentially we would like each site to possess its very own database and have the ability to access the most popular database too.

I'm convinced that developing a jewel to gain access to this second database is what you want, however i am a newcomer to Ruby and Rails.

Anybody done something similar to this before?

Any suggestions regarding how to implement this?

Try with something similar to:

# WARNING: untested code
module DatabaseA
  class Connection < ActiveRecord::Base
    self.abstract_class = true
    establish_connection :my_custom_connection

  def const_missing(name)
    model =
    model.connection = Connection.connection
    const_set(name, model)

Then you need to use your models out of this module:

I've written a jewel to assist with this particular:

It's used by us being produced with rails 2 and rails 3 applications.