Skip to content

Instantly share code, notes, and snippets.

@hannesfostie
Created June 4, 2012 18:47
Show Gist options
  • Save hannesfostie/2870139 to your computer and use it in GitHub Desktop.
Save hannesfostie/2870139 to your computer and use it in GitHub Desktop.
class Doctor < ActiveRecord::Base
attr_accessible :name, :phone, :province_id
has_many :schedules, :dependent => :destroy
has_one :province
end
class Province < ActiveRecord::Base
attr_accessible :name
has_many :schedules
has_many :doctors
end
class Schedule < ActiveRecord::Base
attr_accessible :doctor_id, :date, :province_id
belongs_to :doctor
belongs_to :province
validates_uniqueness_of :province_id, :scope => :date
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment