【发布时间】:2016-12-19 15:05:13
【问题描述】:
我有用户模型和地址,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
【问题讨论】: