Q:

Rails multiple joins return empty set.  Why? 

I'm having problems wrapping my head around using .joins on multiple associations.  This is my model setup:
class Article
  has_many :comments
  has_many :tags
end

class Comment
  belongs_to :article
end

class Tag
  belongs_to :article
end

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:
Article.joins(:tags, :comments).where("(\"tags\".\"tag\" = 'awesome') OR (\"comments\".\"body\" = 'hello')

It's always returning an empty result.  The weirdest thing is that this will work:
Article.joins(:tags).where(:tags => {:tag => "awesome:})

But when I add the other joins symbol, nothing is returned:

Article.joins([:tags, :comments]).where(:tags => {:tag => "awesome"})

Does this make any sense?  Am I doing something stupid? 

A:

joins with an array or symbol argument in Rails always does an INNER JOIN in sql, even when joining multiple tables. 
So when you have no articles with both tags and comments ( or those articles that do have both tags and comments do not match your condition ), you will receive an empty result because you only match these conditions to the cross-section of articles having both comments and tags. 
To get really all articles with tags and comments, do a LEFT JOIN by yourself
Article.joins("LEFT JOIN tags ON tags.article_id = articles.id 
               LEFT JOIN comments ON comments.article_id = articles.id")

And then apply your condition.