This shows one technique for preserving filters on index pages for ActiveAdmin resources, without having to patch the ActiveAdmin core.
It restores any previously-used filters whenever the index page is rendered for a resource, unless the current request is an actual application of new filters. It also properly handles the clear-filters button (via a synchronous Ajax request that happens immediately before the normal filter form processing).
Yes, it's a bit of a hack, but it has worked well for me so far.
Place the controller.rb
file in lib/active_admin/filter_saver/controller.rb
, the index-filters.coffee
somewhere that will be included into ActiveAdmin's JavaScripts. The active_admin.rb
excerpt is from config/initializers/active_admin.rb
.