Answer the question
In order to leave comments, you need to log in
What models and associations should be added to account for attendance?
There are 4 models:
1. Teacher (can lead several courses, or can lead more than one, teacher table)
class Teacher < ActiveRecord::Base
has_and_belongs_to_many :courses
end
class Course < ActiveRecord::Base
has_and_belongs_to_many :teachers
has_many :groups
end
class Group < ActiveRecord::Base
belongs_to :course
has_many :bids
end
class Bid < ActiveRecord::Base
belongs_to :group
end
Answer the question
In order to leave comments, you need to log in
Well, look:
Classes are held at some rate for some group. Attendance refers to a particular student, and a particular class. The teacher will be able to choose a specific lesson and indicate who from the group attended and who did not.
Hence:
class Lesson < ActiveRecord::Base
belongs_to :course
belongs_to :group
end
class Attendance < ActiveRecord::Base
belongs_to :lesson
belongs_to :bid
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question