【发布时间】:2017-02-23 04:57:08
【问题描述】:
我正在尝试在我的 Rails 4 应用程序中编写多条件范围。
class Receipt
# Scope to only get Receipt objects that need to be sent out.
def self.needs_send_receipts
where(sent_receipt: false) && company.employees.size > 0 && company.teams.first.action_items.size >= 15
end
end
这不起作用,我试图找出原因,它应该评估为 true 并返回信息。
【问题讨论】:
-
这个
company.teams.first.action_items.size是一个疯狂的关联链:) -
让我知道我的回答是否有帮助(如果您尝试过)
标签: sql ruby-on-rails ruby postgresql scope