mardi 7 mars 2017

Relationship between student, enrollment, course and section table

I want to get record student enroll the specific course in which section ??? Because one course taught in multiple sections.

class Student < ActiveRecord::Base
    has_many :enrolments
    has_many :courses, through: :enrolment
end
class course < ActiveRecord::Base
    has_many :enrolment
    has_many :students, through: :enrolment
    has_many :sections
end
class enrolment < ActiveRecord::Base
    belongs_to :students
    belongs_to :courses
end
class Section < ActiveRecord::Base
    belongs_to :courses
end

Relationship

Student.first.courses.first.sections

Due to this relationship i got multiple sections. But I want to get single section in which student enroll the specific course ??? Here I am confused do you think this design is good? If not please provide some suggestions.

Aucun commentaire:

Enregistrer un commentaire