title: Multi parameter search via user input - ruby on rails & mongodb
body: <p>I have a web page where a user can search through documents in a mongoDB collection.
  I get the user's input through <code>@q = params[:search].to_s</code></p>
  
  <p>I then run a mongoid query:<br>
  <code>@story = Story.any_of( { :Tags =&gt; /#{@q}/i}, {:Name =&gt; /#{@q}/i}, {:Genre =&gt; {/#{@q}/i}} )</code></p>
  
  <p>This works fine if the user looks for something like 'humor' 'romantic comedy' or 'mystery'. But if looking for 'romance fiction', nothing comes up. <br> Basically I'd like to add 'and' 'or' functionality to my search so that it will find documents in the database that are related to all strings that a user types into the input field.<br><br>
  How can this be done while still maintaining the substring search capabilties I currently have?<br>Thanks in advance for help!<br><br>
  <strong>UPDATE:</strong>
  Per Eugene's comment below...
  I tried converting to case insensitive with  <code>@q.map! { |x| x="/#{x}/i"}</code>. It does save it properly as <code>["/romantic/i","/comedy/i"]</code>. But the query <code>Story.any_of({:Tags.in =&gt; @q}, {:Story.in =&gt; @q})</code>finds nothing.
  When I change the array to be <code>["Romantic","Comedy"]</code>. Then it does.
  How can I properly make it case insensitive?</p>
  
  <p><strong>Final:</strong><br>
  Removing the quotes worked. 
  However there is now no way to use an <code>.and()</code> search to find a book that has both words in all these fields.</p>