NoMethodError: 未定义的方法 'where'



账单表有office_id(办公室表与账单表有许多关系(和issue_id(问题表与账单表有许多关系(。

我想要属于满足以下条件的办公室的所有账单的billings_ids。一个办公室可以有多个billing_ids。

每个办公室都应收到一封电子邮件,其中包含有关问题的所有帐单信息。

我不确定我是否能够解释。

namespace :office do
desc "send reminder emails"
task send_reminder: :environment do
Office.all.each do |office|
office.issues.each do |issue|
issue.where("issues.amount > 0").joins(:billings).where (issue.billings.last.date < Message.last.date)
end
ReminderWorker.perform_async(billing_ids)
end
end
end

你可以这样做issue.billings.where("billings.date < ?", Message.last.date)它会起作用

where

处理对象集合而不是单个对象。

最新更新