Recently, in the past three months or so, ActiveAdmin has updated their master branch to add Rails 4.1 support and migrate away from MetaSearch and on to Ransack for their filters.

If you use the stock filters or shallow relation filters then more than likely your current ActiveAdmin filters will continue to work. However, if you need more complex filtering or previously had defined “search_methods” in your models, you will need to update your code to make use of Ransack’s “ransacker” method instead. Your filter declarations in your ActiveAdmin models are the same format and can remain untouched but you may have to update the filter names and labels.

Like before, you will require changes in two files for a complex filter: one in your ActiveAdmin register and one in the associated model. Below is an example where an Order exists with many Products which each have one ProductColor and we want a drop-down select filter at the Order level for ProductColor:

/app/admin/order.rb

ActiveAdmin.register Order do
  
...
filter :product_color_in, :as => :select, :label => 'Containing Product Color', :collection => proc { ProductColors.order(:name) }
...
end

 

/app/models/order.rb

class Order < ActiveRecord::Base
  has_many :products # and Product belongs_to a ProductColor
  
...
ransacker :product_color, formatter: proc { |selected_pc_id| results = Order.has_pc(selected_pc_id).map(&:id) results = results.present? ? results : nil }, splat_params: true do |parent| parent.table[:id] end
def self.has_pc(pc_id) self.joins(:products).where(products: {product_color_id: pc_id}) end
...
end

Sources