title: Get multiple records with one query
body: <h2>User table:</h2>
  
  <p>name lastname</p>
  
  <blockquote>
    <p>Bob Presley<br>
    Jamie Cox<br>
    Lucy Bush<br>
    Roman Cox  </p>
  </blockquote>
  
  <h2>Find users</h2>
  
  <pre><code>q = Query.new("Bob Presley, Cox, Lucy")
  q.find_users =&gt; {0=&gt;{:name=&gt;"Bob", :lastname=&gt;"Presley"}, 1=&gt;{:lastname=&gt;"Cox"}, 2=&gt;{:name=&gt;"Lucy"}}
  </code></pre>
  
  <h2>Question:</h2>
  
  <p>I've got hash with few names and lastnames. I need to build Activerecord query to fetch all users from that hash. </p>
  
  <p>If i have name and lastname I should find user with exactly the same name and lastname.</p>
  
  <p>If I have only lastname or name I should find all users with this name or lastname. So when i search for :lastname => Cox it should return two users [Roman Cox,Jamie Cox]</p>
  
  <p>I can do</p>
  
  <pre><code>object = []
  hash = q.find_users
  hash.each do |data|
   #Pseudocode
   # object &lt;&lt; User.where(:name =&gt; if data[:lastname] exist, :lastname =&gt; if data[:name] exist)
  end
  </code></pre>
  
  <p>But I think it is higly inefficient. How should I do this ?</p>
  
  <h2>Environment</h2>
  
  <p>rails: 3.0.3<br>
  ruby: 1.9.2-head<br>
  gem: meta_search <a href="https://github.com/ernie/meta_search" rel="nofollow">https://github.com/ernie/meta_search</a></p>