title: Rails 4: how to use OR between conditions on find methods
body: <p>My question is similar to <a href="https://stackoverflow.com/questions/3639656/activerecord-or-query">this one</a>, but none of the answers there address my specific issue.</p>
  
  <p>I want to find objects with something like this:</p>
  
  <pre><code>conditions = {first_name: @search OR last_name: @search}
  Stuff.where( conditions )
  </code></pre>
  
  <p>Obviously, this syntax is invalid, but it's the easiest way I can think of to show what I want to do. I want to use the cleaner hash syntax with complex/compound conditions. </p>
  
  <p>I know you can just write it out by hand with "pure string conditions" like this <code>Stuff.where("first_name=#{@search} OR last_name=#{@search}")</code> <em>...but this is NOT what I want to know.</em> </p>
  
  <p><strong>Update</strong> It looks like you can do OR with an array like this: <code>Stuff.where( some_column: ["option1", "option2"])</code>. This is quite useful to know, but it doesn't solve my problem because I need the OR to apply to different key=value pairs... <code>key=value OR key=value</code> not <code>key=value OR value</code>.</p>
  
  <p><strong>Update2</strong> The reason that I don't want to user the SQL string is because I need to build the query in several pieces and I don't know how to do that while still escaping the inserted variables. I haven't tested, but I'm assuming this won't work:</p>
  
  <pre><code>conditions = ["(project_id=? AND sent_to_api=1)", @project_id]
  conditions = conditions + ["first_name=? OR last_name=?", @search, @search]
  Stuff.where( conditions )
  </code></pre>
  
  <p>Hopefully this makes sense. Is there a way to do what I need with the SQL string syntax while still preserving Rails's built-in SQL escaping?</p>