Multiple search filter like the one in freshdesk
I would advise you to implement search in Index action. If there are no search filters passed, then simply return everything (both for HTML and JSON).

You should rebuild a bit of the form so search params are nested, and you won't have to filter them.

Finally, you can move the search logic to model:

class Request
  def self.search(opts={})
    #reject empty filters
    filters = opts.reject(&amp;:blank?)
    where(filters)
  end
end

class RequestsController
  def index
    @requests = Request.search(params[:search])
  end
end


Now you need to worry only about passing correct params (form fields should match db columns). Some transformations may be necessary depending on how you expect to build the query.

Be sure to fully test the form with integration spec; you are relying on view a lot.