ruby-on-railsruby-on-rails-3activeadminmeta-search

ActiveAdmin custom filter with HBTM associations


I'd like to be able to filter an object with this associations

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"

But I recieve an error:

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

Solution

  •   filter :associated_markets_id, collection: proc { Market.all }, as: :select