Active Admin allows me to define filters that are displayed on the index page like so:
ActiveAdmin.register Promo do
filter :name
filter :address
filter :city
filter :state
filter :zip
end
I would like to combine all the fields above into one, so that I can search for Promos that contain the search string in name or full address. My model already has a named scope that I can use:
class Promo < ActiveRecord::Base
scope :by_name_or_full_address, lambda { |q| where('name LIKE :q OR address LIKE :q OR city LIKE :q OR state LIKE :q OR zip LIKE :q', :q => "%#{q}%") }
end
Active admin uses metasearch. For example you can do this:
filter :"subscription_billing_plan_name" , :as => :select, :collection => BillingPlan.all.map(&:name)