lundi 10 juillet 2017

ransack with price range

I have set up the ransack gem and would like to implement a price range. So far I have 3 checkboxes,

<div class='price-range-filter clearfix'>
                        <label class="btn checkbox-filter-btn">
                            <%= check_box_tag('price_range_1', "1", false, class: "display-none check-filter") %>
                            <div class="fs-11">€0 - €199</div>
                        </label>
                        <label class="btn checkbox-filter-btn">
                            <%= check_box_tag('price_range_2', "2", false, class: "display-none check-filter") %>
                            <div class="fs-11">€200 - €499</div>
                        </label>
                        <label class="btn checkbox-filter-btn">
                            <%= check_box_tag('price_range_3', "3", false, class: "display-none check-filter") %>
                            <div class="fs-11">€500 +</div>
                        </label>
                    </div>
<%= f.hidden_field :max_d_p_lteq, id: 'max_price', value: @max_price %>
<%= f.hidden_field :min_d_p_gteq, id: 'min_price', value: @min_price %>

I would like to send min&max value of these checkboxes with jquery. When user selects 1st and 2nd checkbox I can send 0 and 499 etc. But what if an user checks 1st and 3rd checkboxes how can I handle this with ransack?

Should I send array to ransack?

Aucun commentaire:

Enregistrer un commentaire