title: Nested form - how to add existing nested object to parent form?
body: <p>I've got my models setup for a many-to-many relationship:</p>
  
  <pre><code>class Workshop &lt; ActiveRecord::Base
    has_many :workshop_students
    has_many :students, :through =&gt; :student_workshops
  
    accepts_nested_attributes_for :students
  end
  
  class Student &lt; ActiveRecord::Base
    has_many :student_workshops
    has_many :workshops, :through =&gt; :student_workshops
  
    accepts_nested_attributes_for :products
  end
  
  class StudentWorkshop &lt; ActiveRecord::Base
    belongs_to :student
    belongs_to :workshop
  end
  </code></pre>
  
  <p>As you can see above, a student can have many workshops and workshop can have many students.</p>
  
  <p>I've looked at the following Rails casts: <a href="http://railscasts.com/episodes/196-nested-model-form-part-1" rel="nofollow">here</a> and <a href="http://railscasts.com/episodes/197-nested-model-form-part-2" rel="nofollow">here</a>. And most of the online sources I stumble across only show how to do nested forms for creating new objects within the parent form.</p>
  
  <p>I don't want to create a new object. I only want to add an existing object to the parent form. So for example. If I decide to create a new workshop, I'd like to assign existing students to the workshop.</p>
  
  <p>One thing I don't understand is, how do I link students into the workshop form? Second, when the params are passed, what should be in the controller method for update/create? </p>
  
  <p>If anyone can point me to the right direction, I would appreciate it.</p>