Custom ActiveAdmin filter for model method

43 Views Asked by At

I need to create a filter for ActiveAdmin. The challenge is that I'm trying to filter through a model's method, instead of a model's field or column. Here is my code:

class Model < ApplicationRecord

def complicated_method
  if something
   do this
  else
   do that
  end
end

And in my admin file I need:

ActiveAdmin.register Model do
  filter: :complicated_method, as: :numeric

end

Any tips? Thanks

0

There are 0 best solutions below