Skip to content

Instantly share code, notes, and snippets.

@workmad3
Created January 19, 2010 16:53
Show Gist options
  • Save workmad3/281081 to your computer and use it in GitHub Desktop.
Save workmad3/281081 to your computer and use it in GitHub Desktop.
class Student
has_many :enrollments
has_many :courses, :through => :enrollments
has_many :submissions
has_many :assignments, :through => :submissions
end
class Enrollment
belongs_to :student
belongs_to :course
end
class Course
has_many :enrollments
has_many :students, :through => :enrollments
has_many :assignments
has_many :submissions, :through => :assignments
end
class Assignment
belongs_to :course
has_many :submissions
end
class Submission
belongs_to :assignment
belongs_to :student
named_scope :graded, :conditions => ["grade IS NOT NULL"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment