Skip to content

Instantly share code, notes, and snippets.

@fbehrens
Created March 17, 2012 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbehrens/2056193 to your computer and use it in GitHub Desktop.
Save fbehrens/2056193 to your computer and use it in GitHub Desktop.
Using multiple databases in Active Record
equire 'oci8'
require 'activerecord-oracle_enhanced-adapter'
require 'active_record'
class Db1 < ActiveRecord::Base
self.abstract_class = true
establish_connection YAML.load_file('config/database.yml')['db1']
end
class Db2 < ActiveRecord::Base
self.abstract_class = true
establish_connection YAML.load_file('config/database.yml')['db2']
end
# example use
class Person < Db1
end
Db2.connection.select_all 'select * from people'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment