Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope with arity 0 and enum requests compatible #62

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open

Scope with arity 0 and enum requests compatible #62

wants to merge 42 commits into from

Conversation

hachpai
Copy link

@hachpai hachpai commented Jul 15, 2015

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
Copy link
Author

hachpai commented Sep 30, 2015

There's still this issue with scope methods arity...
activerecord-hackery/meta_search#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?

jhund and others added 27 commits November 30, 2015 20:55
join concatenates array elements to create a string with the optional
specified separator. Unfortunately, the resulting string is assumed not
HTML-safe, and so Rails escapes it to be safe. Rails offers a better
alternative, safe_join, that will concatenate elements while retaining
each element’s HTML-safety and returning an HTML-safe string.
Fix stringify_keys! Rails 5 deprication warning
Change array join to safe_join
Don't parse a hypen (-) as an int, also allow 0
@LizPrescott
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants