I want to customize my filter in activeadmin panel for applications panel.
currently i have a filter like this.

and want the filter like this

i do the code for this as follow
For add category element in filter i do as follow code.
There is 3 tables called
- applications
- categories
- application_categories
and i want the filter data from application_categories as per selection on category from filter.
Structure of tables as follow.
applications table :
- id
- name
- status
- developer_id
- version
- language_id ,etc...
categories table
- id
- name
- parent_id
application_categories table
- id
- application_id
- category_id
In activeadmin resource file
app/admin/applications.rb file code
filter :status, :as => :select, :collection => ["pending", "approved", "declined"]
filter :featured, :as => :select
filter :developer, :collection => proc {(Developer.all).map{|d| [d.company_name, d.id]}}
filter :category , :collection => proc {(Category.all).map{|c| [c.name,c.id]}}
filter :name
filter :version
filter :tags
In application model file
in model app/models/application.rb
belongs_to :developer
belongs_to :bundle
belongs_to :license
belongs_to :language
belongs_to :category
has_many :application_categories, :dependent => :destroy
has_many :categories, :through => :application_categories
It’s display category element in filter panel, but when we select any category and click on filter it’s generate an error as shown below :
Mysql2::Error: Unknown column 'applications.category_id' in 'on clause': SELECT COUNT(DISTINCT count_column) FROM (SELECT applications.id AS count_column FROM applications LEFT OUTER JOIN categories ON categories.id = applications.category_id WHERE categories.id = 32 LIMIT 30 OFFSET 0) subquery_for_count