У меня есть выбор, который пользователь может отфильтровать в своем поиске:
Они делают то, что должны делать.Но после отправки эти значения исчезают из выбора.
Вопрос: как я могу сохранить эти фильтры, вставленные пользователем после его отправки?
Вот мой код:
<%= form_tag filter_vehicles_path, method: 'get', id: 'form_filter_vehicles' do %>
<h4><strong>
<span>Fabricante</span>
<%= collection_select :manufacturer, :manufacturer_id, Manufacturer.joins(:vehicles).uniq, :id, :name, {include_blank: true}, {class: "manufacturer_dropdown"} %>
<span>Modelo</span>
<%= grouped_collection_select :model, :model_id, Manufacturer.order(:name), :models, :name, :id, :name, {include_blank: true}, {class: "model_dropdown", data: {models: @models}} %>
<span>Preço</span>
<%= select_tag :price_start, options_for_select([price(250), price(500), price(1000), price(2000), price(3000), price(4000), price(5000), price(6000), price(7000), price(8000), price(9000),price(10000), price(12000), price(14000), price(16000), price(18000), price(20000), price(22000), price(24000), price(26000), price(28000), price(30000), price(32000), price(34000), price(36000), price(38000), price(40000), price(50000), price(60000), price(70000), price(80000), price(90000), price(100000), price(150000), price(200000)]), include_blank: true, class:"select2PriceFrom" %>
<%= select_tag :price_ending, options_for_select([price(250), price(500), price(1000), price(2000), price(3000), price(4000), price(5000), price(6000), price(7000), price(8000), price(9000),price(10000), price(12000), price(14000), price(16000), price(18000), price(20000), price(22000), price(24000), price(26000), price(28000), price(30000), price(32000), price(34000), price(36000), price(38000), price(40000), price(50000), price(60000), price(70000), price(80000), price(90000), price(100000), price(150000), price(200000)]), include_blank: true, class:"select2PriceTo" %>
<span>Ano</span>
<%= select_tag :year_start, options_for_select((1990..Date.today.year).to_a.reverse + ["1980", "1970", "1960", "1950", "1940", "1930", "1920", "1910", "1900"]), {include_blank: true, maxlength: 4, class:"select2YearFrom"} %>
<%= select_tag :year_ending, options_for_select((1990..Date.today.year).to_a.reverse + ["1980", "1970", "1960", "1950", "1940", "1930", "1920", "1910", "1900"]), {include_blank: true, maxlength: 4, class:"select2YearTo"} %>
<span>Quilómetros</span>
<%= select_tag :kms_start, options_for_select([ kms(5000), kms(10000), kms(15000), kms(20000), kms(25000), kms(30000), kms(35000), kms(40000), kms(45000), kms(50000), kms(75000), kms(100000), kms(125000), kms(150000), kms(175000), kms(200000), kms(225000), kms(250000), kms(275000), kms(300000), kms(350000), kms(400000), kms(500000)]), include_blank: true, class:"select2KmFrom" %>
<%= select_tag :kms_ending, options_for_select([ kms(5000), kms(10000), kms(15000), kms(20000), kms(25000), kms(30000), kms(35000), kms(40000), kms(45000), kms(50000), kms(75000), kms(100000), kms(125000), kms(150000), kms(175000), kms(200000), kms(225000), kms(250000), kms(275000), kms(300000), kms(350000), kms(400000), kms(500000)]), include_blank: true, class:"select2KmTo" %>
<%= submit_tag "Pesquisar" %>
</strong></h4>
<% end %>
Кстати, я использую библиотеку Select2.js.
Заранее спасибо!