= ?", Time.zone.now.beginning_of_week) -6ren">
gpt4 book ai didi

ruby-on-rails - 歧义栏

转载 作者:行者123 更新时间:2023-12-02 15:13:45 25 4
gpt4 key购买 nike

我的模型中有一个范围

scope :created_this_week, -> { where("created_at >= ?", Time.zone.now.beginning_of_week) }

这会正确返回该周创建的职位空缺数量。

现在我需要查看这些空缺中有多少具有匹配(每个空缺可以有多个匹配)且状态为“已申请”或“已接受”

所以我尝试做以下事情:

Vacancy.created_this_week.includes(:matchings)
.where(matchings: {state: ["accepted", "applied"]})

但是我得到以下错误

PG::AmbiguousColumn: ERROR:  column reference "created_at" is ambiguous

最佳答案

用这个更新你的范围,这应该可以解决歧义。

scope :created_this_week, -> { where("vacancies.created_at >= ?", Time.zone.now.beginning_of_week) }

关于ruby-on-rails - 歧义栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41746753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com