title: Rails 3 ActiveRecord query using both SQL IN and SQL OR operators
body: <p>I'm writing a Rails 3 ActiveRecord query using the "where" syntax, that uses both the SQL IN and the SQL OR operator and can't figure out how to use both of them together.</p>
  
  <p>This code works (in my User model):</p>
  
  <pre><code>Question.where(:user_id =&gt; self.friends.ids)
  #note: self.friends.ids returns an array of integers
  </code></pre>
  
  <p>but this code</p>
  
  <pre><code>Question.where(:user_id =&gt; self.friends.ids OR :target =&gt; self.friends.usernames)
  </code></pre>
  
  <p>returns this error</p>
  
  <pre><code>syntax error, unexpected tCONSTANT, expecting ')'
  ...user_id =&gt; self.friends.ids OR :target =&gt; self.friends.usern...
  </code></pre>
  
  <p>Any idea how to write this in Rails, or just what the raw SQL query should be?</p>