I'm using the great filterrific plugin by ClearCove.
I want to reset the filters when a page gets re-loaded. Currently, it's keeping the last search filter saved which is confusing IMO.
Here's my controller:
def index
@filterrific = initialize_filterrific(
current_user.patients,
params[:filterrific],
:select_options => {
sorted_by: Patient.options_for_sorted_by },
) or return
@patients = @filterrific.find.page(params[:page])
@templates = Template.all
gon.root_url = root_url
end
I could do this the hack-y way which would be to use Jquery to click the reset_filterrific_url which is rendered in the view. But that seems wrong. How do I clear the filters whenever page is loaded?
filterrific params are persisted in the browser session. You can disable session persistence by adding the
persistence_id
option:More info at the filterrific documentation.