title: Rails association nil in after_initialize
body: <p>I have two models with a one to many association. I want to set a default value on the child model at initialization based on some state of the parent. This involves having an after_initialize callback fire on the child that needs to access the parent through the belongs_to association. The problem is that when I instantiate the child using the build method, the association to the parent is nil in the after_initialize callback. Is this expected behaviour? I'm on rails 3.0.6</p>
  
  <p>A toy example:</p>
  
  <pre><code>class Merchant &lt; ActiveRecord::Base
      has_many :products
  end
  
  class Product &lt; ActiveRecord::Base
      belongs_to :merchant
  
      after_initialize :set_default_value
  
      def set_default_value
          if merchant.state
              self.foo = some_value
          else
              self.foo = some_other_value
          end
      end
  end
  </code></pre>
  
  <p>And in a controller:</p>
  
  <pre><code>product = merchant.products.build
  </code></pre>
  
  <p>In the call to set_default_value, merchant is nil though it seems that it shouldn't be.</p>