I wanted to clarify the behavior of multi-scope uniqueness validation. The documentation says:
Or even multiple scope parameters. For example, making sure that a teacher can only be on the schedule once per semester for a particular class.
class TeacherSchedule < ActiveRecord::Base
validates_uniqueness_of :teacher_id, :scope => [:semester_id, :class_id]
end
My understanding of this is that I could have a teacher teaching two classes in the same semester but not the same class, and I could have a teacher teaching the same class in different semesters. Is this correct? All 3 fields must match some existing record in order for validation to fail?
Is there a way to validate it so that it fails if either semester_id or class_id matches?