title: In Rails how do I build a has_many association that has a scope
body: <p>I have something like the following:</p>
  
  <pre><code>class Project &lt; ActiveRecord::Base
    has_many :project_people
    has_many :people, :through =&gt; :project_people
  end
  
  class Person &lt; ActiveRecord::Base
    has_many :project_people
    has_many :projects, :through =&gt; :project_people
  end
  
  class ProjectPerson &lt; ActiveRecord::Base
    belongs_to :project
    belongs_to :person
    scope :lead, where(:is_lead =&gt; true)
    scope :member, where(:is_lead =&gt; false)
  end
  </code></pre>
  
  <p>When adding a "lead" ProjectPerson to a new Project, it appears to build correctly, but when calling "@project.project_people" the array is empty:</p>
  
  <pre><code>@project = Project.new
   =&gt; #&lt;Project id: nil, name: nil&gt;
  @project.project_people.lead.build
   =&gt; #&lt;ProjectPerson id: nil, project_id: nil, person_id: nil, is_lead: true&gt;
  @project.project_people
   =&gt; []
  </code></pre>
  
  <p>When I try this without the scope, the ProjectPerson shows up in the array:</p>
  
  <pre><code>@project.project_people.build
   =&gt; #&lt;ProjectPerson id: nil, project_id: nil, person_id: nil, is_lead: false&gt;
  @project.project_people
   =&gt; [#&lt;ProjectPerson id: nil, project_id: nil, person_id: nil, is_lead: false&gt;]
  </code></pre>
  
  <p>How can I get it so that built scoped association records are also included?</p>
  
  <p><strong>UPDATE</strong>: This is an old question that's recently gained some attention. Originally I included a simple example of two scopes that use a boolean. A couple of the recent answers (Feb 2014) have focused on my specific examples instead of the actual question. My question was not for the "lead" and "member" scopes specifically (sometimes scopes are a lot more complex than this), but rather, if it's possible to use a scope and then the <code>build</code> method on an ActiveRecord model. I'm hoping I'm wrong, but there currently doesn't seem to be support for this.</p>