2012-03-20 56 views
3

我希望能夠與這個協會與HBTM協會ActiveAdmin自定義過濾器

ActiveAdmin.register Vendor do 
    filter :"market" , :as => :select, :collection => Market.all 
end 

Model Market 
    has_and_belongs_to_many :vendors 
Model Vendor 
    has_and_belongs_to_many :associated_markets, :class_name => "Market" 

過濾的對象,但我收到一個錯誤:

undefined method `market_eq' for #<MetaSearch::Searches::Vendor:0x007f9f5c02dd18> 

回答

3
filter :associated_markets_id, collection: proc { Market.all }, as: :select 
+1

爲了擴大他的回答在這裏您需要使用關聯模型的屬性名稱(例如':associated_markets_id')而不是模型本身的名稱(':market')。 – ScottJShea 2013-06-26 17:55:20