Skip to content

Instantly share code, notes, and snippets.

@briandoll
Created November 26, 2009 04:34
Show Gist options
  • Save briandoll/243240 to your computer and use it in GitHub Desktop.
Save briandoll/243240 to your computer and use it in GitHub Desktop.
class Hospital < AcitveRecord::Base
has_many :hospital_doctors
# Note: has_many_elsewhere is provided by the st-elsewhere gem
has_many_elsewhere :doctors, :through => :hospital_doctors
end
class HospitalDoctor < ActiveRecord::Base
belongs_to :hospital
belongs_to :doctor
end
class TransactionalBase < ActiveRecord::Base
self.abstract_class = true
establish_connection "#{RAILS_ENV}-transactional"
end
class Doctor < TransactionalBase
has_many :hospital_doctors
has_many :hospitals, :through => :hospital_doctors
end
# The following conventional methods are available for Hospital:
# hospital.doctors, hospital.doctors=, hospital.doctor_ids, hospital.doctor_ids=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment