i have User model and (teacher, student and principle) inherit from it using STI
every class has many students and one teacher only. every student has many classes. every class has many student
class Class < ApplicationRecord
has_and_belongs_to_many:students
belongs_to:teacher
has_many:periods
end
class User < ApplicationRecord
has_and_belongs_to_many:students
belongs_to:teacher
has_many:periods
end
class Teacher < User
has_many:classes
end
class Student < User
has_and_belongs_to_many:classes
has_many:period
end
class Period < ApplicationRecord
belongs_to:teacher
belongs_to:student
end
every class has many period.
how can i set attendance for class as every period has its own attendance for each student? how i create relationship between user and class and period and attendance?
class Attendance < ApplicationRecord
????????
end