I've created a multi filter widget using a search_field_tag, and multiple check_box_tags and I can't seem to figure out how to maintain the checked checkboxes state throughout the session. So for instance if a user filters on several checkboxes and then visits a few other pages and returns to the search/filter page all of the filters previously selected are now blank.
I would like to show the filtered/checked state throughout the browser session and clear it out when the browser is closed.
I hope my question clear enough but if it isn't I can provide a better example.
Any pointers would be greatly appreciated.
Thanks so much.
Great question! I would say that when you submit the search, you can just save the params to
cookies. Something like this:
<%= check_box_tag 'genre', 'rock', cookies['genre'] %>
#controller cookies['genre'] = params[:genre]
And then when you render the form again you can set the checked option to the value of the cookie (like you see here as the 3rd argument of check_box_tag).