title: using nested forms with has_many through - can't assign mass attributes
body: <p>I have read pretty much every question here about the nested forms with has_many through associations, but I can't get my model to work. Can someone please help?</p>
  
  <p>There are 2 models: archetypes and skirtpreferences, linked through a skirtpreferencing model. </p>
  
  <p>Here are the models:</p>
  
  <blockquote>
    <p>class Archetype &lt; ActiveRecord::Base   attr_accessible :occasion,
    :skirt_partworth, :title, :skirtpreferencings_attributes</p>
    
    <p>has_many :skirtpreferencings   has_many :SkirtPreferences, :through
    => :skirtpreferencings   accepts_nested_attributes_for :SkirtPreferences   accepts_nested_attributes_for :skirtpreferencings
    end</p>
    
    <p>Blockquote</p>
    
    <p>class Skirtpreferencing &lt; ActiveRecord::Base   attr_accessible
    :archetype_id, :skirt_preference_id, :skirtpreferencing_attributes</p>
    
    <p>belongs_to :archetype   belongs_to :SkirtPreferences<br>
    accepts_nested_attributes_for :SkirtPreferences</p>
    
    <p>end</p>
    
    <p>class SkirtPreference &lt; ActiveRecord::Base   attr_accessible
    :archetype_id, ....</p>
    
    <p>has_many :skirtpreferencings   has_many :archetypes, :through =>
    :skirtpreferencings</p>
    
    <p>end</p>
  </blockquote>
  
  <p>The form looks like this and that is displaying just fine:</p>
  
  <blockquote>
    <p>&lt;%= form_for(@archetype) do |f| %>   ...   
        &lt;%= f.fields_for :skirtpreferencing do |preference_builder| %>
          &lt;%= preference_builder.fields_for :SkirtPreferences do |builder| %>
        &lt;%= render "skirt_preferences_field", :f => builder %>
        &lt;% end %>    &lt;% end %> ...</p>
  </blockquote>
  
  <p>I imagine I hav to do something in the controllers, but I am not sure exactly what. </p>
  
  <p>Thanks!</p>
  
  <p>Adding the Controllers:</p>
  
  <pre><code>class ArchetypesController &lt; ApplicationController
  
   def new
   @archetype = Archetype.new
   @archetype.skirtpreferencings.build
  end
  
      # GET /archetypes/1/edit
  def edit
    @archetype = Archetype.find(params[:id])
  end
  
   def create
   @archetype = Archetype.new(params[:archetype])     
  end 
  
  
  class SkirtPreferencesController &lt; ApplicationController   
  
   def new
   @skirt_preference = SkirtPreference.new
   end 
  
   def edit
   @skirt_preference = SkirtPreference.find(params[:id])
   end
  
  
   def create
   @skirt_preference = SkirtPreference.new(params[:skirt_preference])
  
   end
  </code></pre>