Created
March 17, 2012 07:35
-
-
Save fbehrens/2056193 to your computer and use it in GitHub Desktop.
Using multiple databases in Active Record
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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