Bhaskara Rao
Bhaskara Rao

Reputation: 43

Active admin customize filter only specific attribute

I have active admin integrated to my app. In Users section the filter is having too many attributes and if I have to customize one the condition in the filter I have to re-write the entire filter again. Can someone suggest me a way to modify a specific condition of the filter than rewriting the entire filter. I want to modify condition for Names list from the attachment.

Like here I have to re-write all the conditions for the filter, instead I want to update a specific filter condition

 filter :website_users
  filter :identities
  filter :names, :collection => proc {(Name.all).map{|c| [c.text, c.id]}}
  filter :competitions
  filter :suggested_names, :collection => proc {(Name.all).map{|c| [c.text, c.id]}} 

Filter with conditions

Upvotes: 4

Views: 3245

Answers (1)

Timo Schilling
Timo Schilling

Reputation: 3073

preserve_default_filters! # build the default filters
remove_filter :website_users # remove a default filter
filter :names, collection: proc { Name.all.map{ |c| [c.text, c.id] } }

Upvotes: 7

Related Questions