title: Find all associated objects by specific condition
body: <hr>
  
  <pre><code>class QuestionGroup &lt; ActiveRecord::Base
    has_many :questions
  end
  
  class Question &lt; ActiveRecord::Base
    belongs_to :question_group
    has_many :question_answers
    has_many :question_users_answers, :through =&gt; :question_answers, :source =&gt; :user_question_answers
  
    def self.questions_without_answers(user_id)
      select {|q| q.question_users_answers.where(:user_id=&gt;user_id).empty?}
    end
  end
  
  class QuestionAnswer &lt; ActiveRecord::Base
    belongs_to :question
    has_many :user_question_answers
  end
  </code></pre>
  
  <p>I need find all Questions if they have no user answers I did it by class method <strong>self.questions_without_answers(user_id)</strong></p>
  
  <p>But how can I find all QuestionGroups where present questions_without_answers and for particular user? </p>
  
  <p>P.S: I need to find all unanswered questions and all groups that own these questions, can I do it by <em>find</em> or <em>named-scope</em>?</p>
  
  <p><strong>UPDATED:</strong></p>
  
  <pre><code>  def self.groups_without_answers(user_id)
      questions_ids = Question.questions_without_answers(user_id).map {|q| q.id}
      all(:conditions =&gt; "id in (select distinct question_group_id from questions where id in (#{questions_ids.join(',')}))")
    end
  </code></pre>
  
  <p>But I think it is not good or maybe I wrong? </p>