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:
@filterrific = initialize_filterrific(
current_user.patients,
params[:filterrific],
:select_options => {
sorted_by: Patient.options_for_sorted_by
},
:persistence_id => false,
) or return
More info at the filterrific documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With