在我的prescription.rb
模型中,我写了以下工作scope
请注意:prescription has_many patient_prescriptions
scope :undeleted_prescriptions, -> { includes(:patient_prescriptions).where(patient_prescriptions: { is_deleted: false })}
现在我希望它还返回那些is_deleted的记录:nil例如 所有记录其中is_deleted为false或nil
答案 0 :(得分:4)
试试这个:
scope :undeleted_prescriptions, -> { includes(:patient_prescriptions).where(patient_prescriptions: { is_deleted: [false,nil] })}