filterrific icon indicating copy to clipboard operation
filterrific copied to clipboard

reset_filterrific_url() should respect the :as option of the form

Open carlosescri opened this issue 9 years ago • 3 comments

If you use:

<%= form_for_filterrific @filterrific, as: :filter do |f| %>
<% end %>

the params prefix will be filter but the reset_filterrific_url() uses the default filterrific one:

?filterrific[reset_filterrific]=true

instead of:

?filter[reset_filterrific]=true

I think that an :as option in the helper would suffice.

carlosescri avatar May 26 '15 14:05 carlosescri

@carlosescri using filterrific as name for the param is an important convention that has implications through large parts of filterrific. Allowing to override the name would make the code significantly more complex, so I prefer not to do it.

Especially since I can't think of a good reason to change the param name. Why do you want to change it?

jhund avatar May 26 '15 15:05 jhund

Well it's just a personal preference. When I develop I tend to use meaningful parameters or, at least, parameter names that don't make the user think about their meaning.

filterrific sounds good to me as a developer because is a very funny name for a library, but filter is something that my users easily recognize.

If you're not going to do anything then it would be better to enforce the :filterrific prefix here:

https://github.com/jhund/filterrific/blob/master/lib/filterrific/action_view_extension.rb#L15

I had changed it because I thought I could do it safely.

But don't worry. I think I can live with filterrific :-)

carlosescri avatar May 26 '15 16:05 carlosescri

I just meet the same problem, but it is not my preference, but this is real need. I had page with 2 tables which I wanted to service via Filterrific - at the moment I see workarounds:

  • to fork repo and add this functionality
  • to write own helper which allows to do it

As I see it is possible only with small changes in Filterrific::ActionViewExtension and Filterrific::HasResetFilterrificUrlMixin

marcinwasowski avatar Aug 16 '16 07:08 marcinwasowski