has_many 通过查询有一些问题。
在这里使用示例:http: //guides.rubyonrails.org/association_basics.html#the-has_many-through-association
class Physician < ActiveRecord::Base
has_many :appointments
has_many :patients, :through => :appointments
end
class Appointment < ActiveRecord::Base
belongs_to :physician
belongs_to :patient
end
class Patient < ActiveRecord::Base
has_many :appointments
has_many :physicians, :through => :appointments
end
约会表有一个名为约会日期的列
我如何从特定医生那里获得在给定日期预约的所有患者?