我有一个索引管理视图,其中显示了关联的模型City
。我希望能够按城市名称排序,但是当我单击列标题进行排序时,我收到以下错误:
ActiveRecord::StatementInvalid in Admin/deals#index
SQLite3::SQLException: no such column: cities.name: SELECT "deals".* FROM "deals" ORDER BY cities.name desc LIMIT 30 OFFSET 0
索引视图
ActiveAdmin.register Deal do
index do
column :id
column :city
end
...
end
模型
class Deal < ActiveRecord::Base
belongs_to :city
end
如何按城市排序?