title: Rails- Dynamic search on multiple fields
body: <p>I'm trying to write a concern to allow search on multiple fields from different models. I want to insert a search_fields array and generate a where OR query with the params[:query] value like this :</p>
  
  <pre><code>scope = scope.where("LOWER(user_name) LIKE LOWER(?)", "%#{params[:query]}%")
  </code></pre>
  
  <p>it works fine for one value but I need to receive an array of column names (different for different models) and generate a where or query like this (exemple with an array of two items) :</p>
  
  <pre><code>search_fields = ["title", "user_name"]
  
  where("LOWER(title) LIKE LOWER(?) OR LOWER(user_name) LIKE LOWER(?)", "%#{params[:query]}%", "%#{params[:query]}%")
  </code></pre>
  
  <p>I generate the query like this : </p>
  
  <pre><code>query = search_fields.map do |s|
    "LOWER(#{s}) LIKE LOWER(?)"
  end.join(' OR ')
  </code></pre>
  
  <p>and it seems that there is no where_or method implemented. I could not do it by any means, is there any ideas how it is possible to do ?</p>
  
  <p>Thanks for all answers</p>