title: Rails multiple joins return empty set. Why?
body: <p>I'm having problems wrapping my head around using .joins on multiple associations. This is my model setup:</p>
  
  <pre><code>class Article
    has_many :comments
    has_many :tags
  end
  
  class Comment
    belongs_to :article
  end
  
  class Tag
    belongs_to :article
  end
  </code></pre>
  
  <p>I'm trying to find all articles with a comment that has a specific comment body OR a tag with a specific tag text. This is my query:</p>
  
  <pre><code>Article.joins(:tags, :comments).where("(\"tags\".\"tag\" = 'awesome') OR (\"comments\".\"body\" = 'hello')
  </code></pre>
  
  <p>It's always returning an empty result. The weirdest thing is that this will work:</p>
  
  <pre><code>Article.joins(:tags).where(:tags =&gt; {:tag =&gt; "awesome:})
  </code></pre>
  
  <p>But when I add the other joins symbol, nothing is returned:</p>
  
  <p><code>
  Article.joins([:tags, :comments]).where(:tags =&gt; {:tag =&gt; "awesome"})
  </code></p>
  
  <p>Does this make any sense? Am I doing something stupid?</p>