10 6 / 2016
How to write an Active Admin custom filter (custom search)
This will work with pre 1.0.0 versions where active_admin used metasearch gem for filters. Below is how you can add a custom field as filter and use it to generate search results using a custom search function:
For me active_admin did break down when we added a polymorphic association to an existing model, and the filter on association stopped working. We suddenly started seeing “no implicit conversion of nil into String
“ exceptions. I then had to figure out how to write a custom filter for active admin - and believe me it was like walking in the Sahara Desert =P , with little/no documentation around.
Do let me know in case this helped you and I saved you from getting lost in the great Sahara ;)
![image](https://66.media.tumblr.com/8f8889d3dcc38fcfe3e30593029d01dc/tumblr_inline_o8j26p7OOE1rj6oo2_500.jpg)