Ruby on rails rails中citext字段类型的不区分大小写排序

Ruby on rails rails中citext字段类型的不区分大小写排序,ruby-on-rails,ruby,sql-order-by,Ruby On Rails,Ruby,Sql Order By,迁移文件 class ChangeDataTypeOrganisationName < ActiveRecord::Migration[5.1] def up enable_extension :citext change_column :organisations, :name, :citext end def down change_column :organisations, :name, :text disable_extensio

迁移文件

class ChangeDataTypeOrganisationName < ActiveRecord::Migration[5.1]
  def up
    enable_extension :citext
    change_column :organisations, :name, :citext
  end
  
  def down
    change_column :organisations, :name, :text
    disable_extension :citext
  end
end
我想根据办公室名称订购办公室过滤器。我将office name的字段类型设置为text,因此为了使其不区分大小写,我将数据类型更改为citext,以便执行不区分大小写的排序。但排序仍然区分大小写。首先是下位命令,然后是上位命令。请帮我解决这个问题

更新1

PG::UndefinedTable: ERROR:  missing FROM-clause entry for table "offices"
LINE 1: ...$1) ORDER BY "organisations"."updated_at" DESC, LOWER(offices.na...
更新2

组织控制者.rb

def index
 @offices = Organisation.all
 @offices = offices.order(updated_at: :desc)
end
更新3

Ankor
asdas
John Wilson
Abp
Sim Limited

也许你可以试试:

@offices.order('LOWER(organisations.name)')

是的,我也试过了。仍然不起作用PG::AmbiguousColumn:ERROR:列引用“name”不明确我收到此错误请检查问题中的更新1。这是新的错误。你知道我哪里出了问题吗?@user12763413检查updateWell,它说的是,在你的查询中没有找到
offices
表,实际上它似乎在查询中使用
organizations
作为顺序参数。您确定
@offices
确实是
Office
模型的集合吗?您能在获得
@offices
变量的位置添加相关代码吗?@Alteragos请检查更新2。我从组织模型中得到办公室
@offices.order('LOWER(organisations.name)')