2016-12-19 7 views
1

私はユーザーモデルと住所、SocialProfileモデルを持っています。アクティブな管理者のUserリソースのフィルタセクションに "zip"、 "address_line_1"のようなAddressモデルのフィールドを表示したい。アクティブな管理者は、フィルタに関連するモデルフィールドを使用します。

アドレスモデルとして、私はSocialProfile ModelのフィールドをUserの同じリソースに表示したいと考えています。 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 

フィルタ/管理/ 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   

答えて

0

あなたは、関連するモデルをフィルタリングすることができるはずただ

filter :address_zip, as: :string 
filter :social_profile_mobile, as: :string 

、それは意志を使用して、関連するモデルの特定のフィールドのみをフィルタリングします。私はそれらの属性のどれがどのモデルに属しているのかは分からないかもしれませんが、その考えは同じです。

+0

素晴らしい!私のために働いた! 'フィルタ:addresses_zip :: as:文字列 フィルタ:social_profiles_mobile、as::string' – Rishabh

+0

ドキュメントモデルを持っていて、ユーザに属していて、 IdentityDocument Documentに属するモデルDocument AA Resource のようなフィルタを追加することができます**ドキュメントbelongs_to User ** 'filter:user_mobile、as::string'**ドキュメントhas_many IdentityDocument、型はIdentityDocumentの属性です** ' filter:identity_documents_type、as::string ' – Rishabh

関連する問題