module ActiveAdmin::Filters::FormtasticAddons

def column

def column
  column_for method
end

def column_for(method)

def column_for(method)
  klass.columns_hash[method.to_s] if klass.respond_to? :columns_hash
end

def has_predicate?

likely we're dealing with a valid search method.
If the given method has a predicate (like _eq or _lteq), it's pretty
def has_predicate?
  !!Ransack::Predicate.detect_from_string(method.to_s)
end

def humanized_method_name

def humanized_method_name
  if klass.respond_to?(:human_attribute_name)
    klass.human_attribute_name(method)
  else
    method.to_s.public_send(builder.label_str_method)
  end
end

def klass

The resource class, unwrapped from Ransack
def klass
  @object.object.klass
end

def polymorphic_foreign_type?(method)

def polymorphic_foreign_type?(method)
  klass.reflect_on_all_associations.select { |r| r.macro == :belongs_to && r.options[:polymorphic] }
    .map(&:foreign_type).include? method.to_s
end

def reflection_for(method)

def reflection_for(method)
  klass.reflect_on_association(method) if klass.respond_to? :reflect_on_association
end

def scope?

Ransack supports exposing selected scopes on your model for advanced searches.
def scope?
  context = Ransack::Context.for klass
  context.respond_to?(:ransackable_scope?) && context.ransackable_scope?(method.to_s, klass)
end

def searchable_has_many_through?

def searchable_has_many_through?
  if klass.ransackable_associations.include?(method.to_s) && reflection && reflection.options[:through]
    reflection.through_reflection.klass.ransackable_attributes.include? reflection.foreign_key
  else
    false
  end
end

def seems_searchable?

def seems_searchable?
  column_for(method).nil? && (has_predicate? || scope?)
end