how I build a advanced search how this image:
I have my controller, very basic yet:
def index
@q = Product.ransack(params[:q])
@products = @q.result(distinct: true)
end
And have my view:
<%= search_form_for @q do |f| %>
<%= f.label :name_cont, "Name" %>
<br />
<%= f.search_field :name_cont %>
<br />
<%= f.label :brand, "Brand" %>
<br />
<%= f.collection_check_boxes :brand, Product.all, :id, :brand %>
<br />
<%= f.label :hd, "HD" %>
<br />
<%= f.collection_check_boxes :hd, Product.all, :id, :hd %>
<br />
<%= f.label :ram, "RAM" %>
<br />
<%= f.collection_check_boxes :ram, Product.all, :id, :ram %>
<br />
<%= f.submit "Search" %>
<% end %>
But, the only thing that worked on search is the input name. And I have two problems. 1º The checkboxes don't worked. 2º Some checkboxes is repeting because I put Product.all, but too put distinct, but nothing worked =/ Can you help me please?
you can try following for brand, hd and ram