title: Rails how to set predefined attribute value for associations
body: <p>I have a model like </p>
  
  <pre><code>class CqmExternalId &lt; ActiveRecord::Base
          set_table_name :cqm_external_id
          has_many :ipp_measure_ids, :class_name =&gt; "CqmMeasureId", :foreign_key =&gt; "cqm_external_id", :conditions =&gt; [" name = 'IPP'"]
          has_many :numer_measure_ids, :class_name =&gt; "CqmMeasureId", :foreign_key =&gt; "cqm_external_id", :conditions =&gt; [" name = 'NUMER'"]
          has_many :denom_measure_ids, :class_name =&gt; "CqmMeasureId", :foreign_key =&gt; "cqm_external_id", :conditions =&gt; [" name = 'DENOM'"]
          has_many :denex_measure_ids, :class_name =&gt; "CqmMeasureId", :foreign_key =&gt; "cqm_external_id", :conditions =&gt; [" name = 'DENEX'"]
  end
  
  class CqmMeasureId &lt; ActiveRecord::Base
          set_table_name :cqm_measure_id
          belongs_to :cqm_external, :class_name =&gt; "cqm_external", :foreign_key =&gt; "cqm_external_id"
  end
  </code></pre>
  
  <p>How to make <code>ipp_measure_ids</code> association to insert default value on <code>create</code></p>
  
  <pre><code> c = CqmExternalId.first
   c.ipp_measure_ids.create!(:key=&gt;"ABC-1234")  =&gt; #&lt;CqmMeasureId id: 1, name:nil, key:"ABC-1234&gt;"
  
   # I want the name attribute to be initialized automatically as "IPP"
  </code></pre>