jeudi 15 décembre 2016

Limit Ransack drop down options

I am using Ransack and it is working really well on our Data model. Now the issue is, in the dropdown, it shows us all the 15 option like id, name, age, gender, type, location, SSN, company, status etc.

I only want 3 options to be shown in the drop down say name, gender and location (all being text fields). How can I do it ?

data_controller.rb

@search = Data.search(params[:q].try(:merge, m: 'or'))
@datum = @search.result(:distinct=>true).paginate(page: params[:page], per_page: 30)

data.html.erb

    <div class="row">
        <div class="col-lg-10">
            <div class="form_search">
                <%= search_form_for @search, url: search_data_index_path, html: { method: :get, class: "data_search" } do |f| %>
                <%= f.condition_fields do |c| %>
                <%= render "condition_fields", f: c %>
                <% end %>
                <p><%= link_to_add_fields "Add Conditions", f, :condition %></p>
                <br>
                <div class="actions">
                    <%= f.submit "Search", :class => "btn btn-primary" %>
                </div>
                <% end %>
            </div>
        </div>
    </div>

Thanks

Aucun commentaire:

Enregistrer un commentaire