class Health::PhyExamRecordItem < ActiveRecord::Base
belongs_to :phy_exam_record, :class_name=>"Health::PhyExamRecord"
belongs_to :phy_exam_tpl_item, :class_name=>"Health::PhyExamTplItem"
scope :get_record_items, -> (category_id,phy_exam_record_id) {
self.joins(:phy_exam_tpl_item).where("health_phy_exam_record_items.phy_exam_record_id = ?",phy_exam_record_id) & Health::PhyExamTplItem.group_category(category_id)
}
end
说明:scope 方法中进行多表查询需要调用
输出结果不对!