Skip to content

Instantly share code, notes, and snippets.

@dhirengupta
Created September 13, 2011 20:30
class Teacher
has_many :course_memberships, :as => :takeable
has_many :courses, :through => :course_memberships
end
class Student
has_many :course_memberships, :as => :takable
has_many :courses, :through => :course_memberships
end
class CourseMembership
belongs_to :course
belongs_to :takable, :polymorphic => true
end
class Course #note this model is not the polymorhic end
has_many :course_memberships
has_many :teachers, :through => :course_memberships
has_many :students, :through => :course_memberships
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment