lundi 2 janvier 2017

Rails: collection_check_boxes to filter search results

I'm trying to implement a search view which enables users to search other users based on keyword AND multiple checkboxes for their tags. I'm still trying to figure out how to place the collection_check_boxes right, so that view is rendered correctly. Here's what I have so far:

  <%= form_tag users_path, :method => 'get' do %>
    <%= collection_check_boxes :options, :tag_ids, Tag.order(:name), :id, :name, {multiple: true} %>
    <%= text_field_tag :search, params[:search], :placeholder => "Search", :id => "query" %>
    <%= submit_tag "Search", :name => nil, :style => "float:left;"%>
  <% end %>

Can you help me complete the view function above by making sure that, when a user clicks search collection_check_boxes will add something like tag=tag1&tag2&tag3 to the url?




Aucun commentaire:

Enregistrer un commentaire