views:

28

answers:

0

AS it reads I would like to use the same model connecting to different databases, something like this:

require 'rubygems'
require 'active_record'
require "active_resource"

dbs = [ 'db_one' ]

$config = YAML.load_file(File.join(File.dirname(__FILE__), 'database.yml'))
#Tables we use from 3db
class My3DB < ActiveRecord::Base
  self.abstract_class = true
end

dbs.each { |db|
  a=My3DB.new
  a.establish_connection $config[db])

}