title: How do I express a :has_one assocation :through a collection, with a :condition to construct/select "the one"?
body: <p>I've got some models (Rails 3.2) like this, A->B->C, to model a Manager (A) who covers many Areas (B), each of which has many Addresses (C).  One of those addresses is the manager's primary address.  I can't figure out the best way to associate a Manager with his primary address.</p>
  
  <pre><code>class AreaManager &lt; ActiveRecord::Base
    has_many :areas, :dependent=&gt;:destroy
    has_many :addresses, :through=&gt;:areas
    ...
    def primary_address
      self.addresses.where(:primary=&gt;true).first 
        # in fact, there can be only one
    end
  end
  
  class Area &lt; ActiveRecord::Base
    belongs_to :area_manager
    has_many :addresses,:dependent=&gt;:destroy
  end
  
  class Address &lt; ActiveRecord::Base
    belongs_to :area
    attr_accessible :primary 
      # this is the manager's primary address (not the area's)
  end
  </code></pre>
  
  <p>This allows me to say, for example:</p>
  
  <pre><code>a = AreaManager.find(123)
  a.primary_address # =&gt; her primary address
  </code></pre>
  
  <p>But what I really want is a constructor/setter as well as a getter:</p>
  
  <pre><code>a = AreaManager.new
  a.build_primary_address ...
  </code></pre>
  
  <p>I can add to Area:</p>
  
  <pre><code>has_one :primary_address, 
    :class_name=&gt;'Address', 
    :conditions =&gt; {:primary=&gt;true}
  </code></pre>
  
  <p>and this allows me to do</p>
  
  <pre><code>a1 = Area.new
  a1.build_primary_address ... # instantiates an Address with primary = true
  </code></pre>
  
  <p>but when I try to do something similar to AreaManager, by adding</p>
  
  <pre><code>has_one :primary_address, 
    :through=&gt;:areas, 
    :source=&gt;:address, 
    :conditions=&gt;{:primary=&gt;true}
  </code></pre>
  
  <p>and then say:</p>
  
  <pre><code>a = AreaManager.new
  a.build_primary_address ... 
    # instead of creating an area and an address, it croaks
  </code></pre>
  
  <p>I get a ActiveRecord::HasOneThroughCantAssociateThroughCollection exception.  I can't figure out what the right incantation might be (or if there is one).  Is there a Railsy way to do this?  </p>