title: Reusing activerecord scopes on has many through associations
body: <p>Say I have a few activerecord models in my rails 3.1 project that look like this:</p>
  
  <pre><code>class Component &lt; ActiveRecord::Base
      has_many :bugs
  end
  
  class Bug &lt; ActiveRecord::Base
      belongs_to :component
      belongs_to :project
  
      scope :open, where(:open =&gt; true)
      scope :closed, where(:open =&gt; false)
  end
  
  class Project &lt; ActiveRecord::Base
      has_many :bugs
      has_many :components_with_bugs, :through =&gt; :bugs, :conditions =&gt; ["bugs.open = ?", true]
  end
  </code></pre>
  
  <p><strong>In Short:</strong> I have a has_many through association (<code>components_with_bugs</code>) where I want to scope the "through" model. At present I'm doing this by duplicating the code for the scope.</p>
  
  <p>Is there any way to define this has many through association (<code>components_with_bugs</code>) such that I can reuse the <code>Bug.open</code> scope on the through model, while still loading the components in a single database query? (I'm imagining something like <code>:conditions =&gt; Bug.open</code>)</p>