I have the following models:
student class teacher
a student can have multiple classes, a class can have 0 or 1 teachers. I want to be able to call a method on the student to see if they have a specific teacher, and return true or false.
The following code seems to work, but i thought it looked a bit long winded, having to compare each of the teachers attributes against those in the DB.
a_teacher = Teacher.new(:name => "Bob", :age => 30)
self.classes.all(:conditions => ["teacher.name = ? AND teacher.age = ?", a_teacher.name,a_teacher.age], :joins => :teacher)
I thought there might be a way to pass a_teacher into the find, instead of specifying the attribute seperatly. Thanks