I am using advanced search in Ransack, which has a default value of AND. I did this as OR by putting .try (: merge, m: 'or'))
@search = Data.search(params[:q].try(:merge, m: 'or'))
but I cannot remove AND / OR as a group of conditions, as shown in the Ransack demo here http://ransack-demo.herokuapp.com/users/advanced_search p>

How to do this, unfortunately, the Ransack wiki does not mention this.
OUR CODE
data_controller.rb
def search @search = Data.search(params[:q]) @datum = @search.result(:distinct=>true).paginate(page: params[:page], per_page: 10) if params[:q].nil? @datum = Prospect.where(:id => 0).paginate(page: params[:page], per_page: 10) end @page = params[:page] || 0 @pids = @search.result(:distinct=>true).pluck(:id) @search.build_condition
routes.rb
resources :data do collection do get :search post :search, to: 'data#search' end end
data.html.erb
<script type="text/javascript"> var ids = <%= @pids %>; </script> <section class="psf"> <div class="container"> <h1>All Data</h1> <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> <br> <% if !@pids.nil ? %> <div class="total_count"><b><%= @pids.count %> Records Found.</b></div> <% end %>
source share