I have two models lecture and students in rails. A lecture can have many students and a students can have many lectures. So for that I have used has_and_belongs_to_many
.
But how can I implement a constrain that there should be no conflicting lectures(due to start time and end time) for a student.
Both the models are joined by their primary key.
Models of lectures and students are
create_table :lectures do |t|
t.string :title
t.datetime :start_time
t.datetime :end_time
--
create_table :student do |t|
t.string :name