我有这些对象:
class District < ActiveRecord::Base
belongs_to :city
end
class City < ActiveRecord::Base
has_many :districts
end
我想做的(并且到目前为止无法这样做)是:City
在 的索引中有一个列,District
并且该列应该可以在City.name
.
在不崩溃 ActiveAdmin 的情况下,我能做的最接近的事情是:
index do
column City.human_name(:count => :other), :city, :sortable => :city_id
end
这当然不够好;我不想对外键的整数值进行排序。
尝试了类似的东西:sortable => 'city.name'
,给出了一个错误。甚至尝试像在“纯”Rails 上那样做 - :joins => :cities, :sortable => 'city.name'
- 没有运气。尝试了一堆其他愚蠢的东西,很生气,决定谦虚地寻求帮助。
谁能指出我正确的方向?谢谢你的时间。