How to add custom filter to Active Admin?

后端 未结 8 2139
眼角桃花
眼角桃花 2020-12-25 11:04

Active Admin allows me to define filters that are displayed on the index page like so:

ActiveAdmin.register Promo do

  filter :name
  filter :address
  filt         


        
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-25 11:17

    Active Admin uses the meta_search gem for its filters. ORed conditions syntax allows to combine several fields in one query, for example

    Promo.metasearch(:name_or_address_contains => 'brooklyn')
    

    In Active Admin DSL this translates to

    ActiveAdmin.register Promo do
    
      filter :name_or_address, :as => :string
    
    end
    

提交回复
热议问题