I have a Rails 3.2.20 app where I'm stacking several search queries/scopes together which come across as params in a view.
I have everything working so when I make my selections in the select_tag the will persist on page reload using something like this:
<%= select_tag "search[attendant]", options_from_collection_for_select(Medic.order(:medic_name), :medic_name, :medic_name, selected: params[:search].try(:[], :attendant)), prompt: "Select Attendant" %>
I'm trying to do another search criteria using the check_box_tag like so:
<%= check_box_tag "search[unbilled]", selected: params[:search].try(:[], :unbilled) %>
This works when I check the box and it will pass the search param key of unbilled to the model and scope out the records I want properly. The problem is when I click a different page through pagination or reload the page after hitting submit/search the checkbox will not persist.
I'm pretty sure my syntax for the check_box_tag is incorrect. I'd like to figure out how to use selected in the check_box_tag similar to how I do it in the select_tag from my previous example to persist the checkbox tick.
Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire