活动管理员在过滤器中使用相关模型字段

Active Admin use related model fields in filters

我有用户模型和地址、SocialProfile 模型。我想在活动管理员的用户资源的过滤器部分中显示地址模型的字段,如 "zip"、"address_line_1"。

作为地址模型,我想在用户的同一资源中显示 SocialProfile 模型的字段。 如何在 belongs_to 模型的活动管理员中显示下拉列表和文本搜索中的字段?

class User < ActiveRecord::Base
  has_many :addresses
  has_many :social_profiles
end

class Address < ActiveRecord::Base
 belongs_to :user
end

class SocialProfile < ActiveRecord::Base
  belongs_to :user
end

app/admin/user.rb

中的用户资源过滤器
filter :mobile
filter :full_name
filter :zip #to use the address model's "zip" field
filter :source #use social_profile model's "social" field           

您应该能够通过使用

过滤关联的模型
filter :address_zip, as: :string
filter :social_profile_mobile, as: :string 

它只会过滤关联模型的那些特定字段。我可能不了解这些属性中的哪些属性属于哪个模型,但想法是一样的。