Skip to content

Instantly share code, notes, and snippets.

@veader
Created October 18, 2010 15:06
Show Gist options
  • Save veader/632350 to your computer and use it in GitHub Desktop.
Save veader/632350 to your computer and use it in GitHub Desktop.
class ExternalDbModel < ActiveRecord::Base
self.abstract_class = true
establish_connection "external_#{RAILS_ENV}"
# only need this if you want the other db to be readonly
#private
# def after_initialize
# readonly!
# end
end
class InternalModel < ActiveRecord::Base
self.abstract_class = true
end
# this class points to the external DB
class SomeOutsideModel < ExternalDbModel
has_many :foos
end
# this class points to the internal DB
class SomeInsideModel < InternalModel
has_many :bars
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment