There was a question recently in the #RubyOnRails IRC channel on freenode: “How can I retrieve all the questions that don’t have answers?”. This Rails coding example shows the answer.

Two Models

Associations

Finding Questions with No Answers:

Question.includes(:answers).where(answers: {id: nil})

Converse: Finding All Questions that have Answers:

Question.includes(:answers).where.not(answers: {id: nil})

Source