Ruby on rails 如何对关联列进行排序不区分大小写

Ruby on rails 如何对关联列进行排序不区分大小写,ruby-on-rails,ruby,postgresql,activerecord,Ruby On Rails,Ruby,Postgresql,Activerecord,我试图按客户公司名称对所有项目进行排序,但出现以下错误:PG::UndefinedTable:error:表“customers”第1行的子句条目中缺少:。。。其中“项目”。“存档”=$1订单由下级(客户…^:从“项目”中的“项目”中选择“项目”。“存档”=$1订单由下级(客户.公司)ASC 到目前为止,我就是这样尝试的: projects = Project.includes(:customer).order("LOWER(customers.company) ASC") 如果我省略了LOW

我试图按客户公司名称对所有项目进行排序,但出现以下错误:
PG::UndefinedTable:error:表“customers”第1行的子句条目中缺少:。。。其中“项目”。“存档”=$1订单由下级(客户…^:从“项目”中的“项目”中选择“项目”。“存档”=$1订单由下级(客户.公司)ASC

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

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

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

您需要使用

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