我想查询哪里我得到所有与类D,具有特定名称(类D具有名称列)的关系的类。但也有类B和C之间,实际上我不知道如何处理与连接和合并。通过多重关系查询ActiveRecord
的关系如下:
class Appointment
has_many :booked_classes
has_many :classes, through: :booked_classes
end
class BookedClass
belongs_to :Appointment
belongs_to :Class
end
class Class
belongs_to :Teacher
has_many: BookedClasses
end
class Teacher
has_many :Appointmentss, through :Clasesses
has_many :Classes
end
用户'包括'方法 –