Rails Active Admin如何使用2列config.sort_order(关联中的1列)

在Active Admin中想知道如何设置带有2列的config.sort_order,其中第一列来自同一模型,第二列来自关联模型?

ActiveAdmin.register Race do menu parent: :races, :label => proc{ I18n.t('activerecord.models.races') } belongs_to :meeting, :optional => true #need to order by "meetings.date desc races.time desc" config.sort_order = "?" controller do def scoped_collection end_of_association_chain.includes(:meeting) end end end 

config.sort_order将接受多个字段的排序,格式为“ field1_(asc | desc),field2_(asc | desc) ”保留向后兼容性。

请查看此链接以供参考。 https://github.com/activeadmin/activeadmin/pull/2432 。 它可以解决您的问题。