gpt4 book ai didi

ruby-on-rails - 如何排序不区分大小写的关联列

转载 作者:太空宇宙 更新时间:2023-11-03 17:14:57 26 4
gpt4 key购买 nike

我正在尝试按客户公司名称对我的所有项目进行排序,但出现此错误:PG::UndefinedTable: ERROR: missing FROM-clause entry for table "customers"LINE 1: ... WHERE “项目”。

到目前为止我是这样尝试的:

projects = Project.includes(:customer).order("LOWER(customers.company) ASC")

如果我省略 LOWER(...) 一切正常。

最佳答案

您需要使用 references 来编写它.

Project.includes(:customer)
.order("LOWER(customers.company) ASC")
.references(:customers)

关于ruby-on-rails - 如何排序不区分大小写的关联列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31409456/

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