Wednesday, 2 March 2022

Add AJAX FILTER IN ACTIVE ADMIN:

ADD select2 gem in you gem file

https://github.com/platanus/activeadmin_addons/blob/master/docs/select2_search.md

input form:

f.input :category_id, as: :search_select, url: admin_categories_path,
          fields: [:name, :description], display_name: 'name', minimum_input_length: 2,
          order_by: 'description_asc'

OR
f.inputs do
      f.input :account_id, as: :search_select, url: admin_users_path,
          fields: [:first_name], display_name: 'first_name', minimum_input_length: 2,
          order_by: 'id'
    end

ON FILTER:
 filter :category_id, as: :search_select_filter, url: proc { admin_categories_path },
         fields: [:name, :description], display_name: 'name', minimum_input_length: 2,
         order_by: 'description_asc'