Skip to content

Instantly share code, notes, and snippets.

@wioux
Created March 11, 2014 20:38
Show Gist options
  • Save wioux/9494494 to your computer and use it in GitHub Desktop.
Save wioux/9494494 to your computer and use it in GitHub Desktop.
class CoursePrerequisite < ActiveRecord::Base
belongs_to :course
belongs_to :prerequisite, :class_name => 'Course'
attr_accessible :required
belongs_to :suggested_by, :class_name => 'User'
end
class Course
has_many :course_prerequisites
has_many :prerequisites, :class_name => 'Course', :through => :course_prerequisites, :dependent => :destroy
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment