filterrific icon indicating copy to clipboard operation
filterrific copied to clipboard

Scope with arity 0 and enum requests compatible

Open hachpai opened this issue 9 years ago • 2 comments

Hello,

I really wanted to use my enum-styled queries and 0-parameters scope. I've adapted filterriffic in a way to afford that. As arity for scope and enums doesn't work as expected I use the ArgumentError exception.

filterrific_available_filters.each do |filter_name|
    filter_param = filterrific_param_set.send(filter_name)
      next if filter_param.blank? # skip blank filter_params
      begin
        ar_rel = ar_rel.send(filter_name, filter_param)
      rescue ArgumentError #if we have a scope with arity 0 or enum query, we can perform the request without the parameter
        ar_rel = ar_rel.send(filter_name) if (filter_param == 1)
      end
    end
    ar_rel
end

hachpai avatar Jul 15 '15 14:07 hachpai

There's still this issue with scope methods arity... https://github.com/activerecord-hackery/meta_search/issues/19 I think it would be better to use the scope arity in order to define the use of params. That would let checkboxes activate filter.

@jhund what's your mind about that?

hachpai avatar Sep 30 '15 15:09 hachpai

Hi! Is there more work to be done to merge this one? Happy to help.

LizPrescott avatar Oct 16 '18 13:10 LizPrescott