Skip to content

Instantly share code, notes, and snippets.

@jbonney
Created June 12, 2013 11:32
Show Gist options
  • Select an option

  • Save jbonney/5764538 to your computer and use it in GitHub Desktop.

Select an option

Save jbonney/5764538 to your computer and use it in GitHub Desktop.
db1_production:
adapter: mysql2
encoding: utf8
database: db1
username: user_db1
password: mypass
host: localhost
timeout: 5000
db2_production:
adapter: mysql2
encoding: utf8
database: db2
username: user_db2
password: mypass
host: other_host
timeout: 5000
module DatabaseConnections
class Db1 < ActiveRecord::Base
self.abstract_class = true
establish_connection configurations["db1_#{Rails.env}"]
end
class Db2 < ActiveRecord::Base
self.abstract_class = true
establish_connection configurations["db2_#{Rails.env}"]
end
end
class ModelStoredInDb1 < DatabaseConnections::Db1
end
class ModelStoredInDb2 < DatabaseConnections::Db2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment