title: Rails 3 - Create View to Insert Multiple Records
body: <p>I have what seems like a simple query. I need to create a view that will accept multiple records based on a single model. In my case the model is Project, which has 1 foreign key (person) and 2 fields time, role. I need to create a view (form) to insert 5 roles. </p>
  
  <pre><code>&lt;%= form_for(@project) do |f| %&gt;
   &lt;% 5.times do |index|%&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :position %&gt;&lt;br /&gt;
      &lt;%= f.text_field "fields[#{index}][stime]" %&gt;
    &lt;/div&gt;
  
   &lt;% end %&gt;
   &lt;div class="actions"&gt;
       &lt;%= f.submit %&gt;
   &lt;/div&gt;  
  &lt;% end %&gt;
  </code></pre>
  
  <p>I get an error message: undefined method `fields[0][stime]' </p>
  
  <p>I do not think the railscasts for nested models is what I need. </p>
  
  <p>How would I go about creating this?</p>
  
  <p>EDIT: The Project model code is below:</p>
  
  <pre><code>class Project &lt; ActiveRecord::Base
     belongs_to :person
     attr_accessible :role, :stime
  end
  </code></pre>
  
  <p>The Projects_Controller code for the new method is below:</p>
  
  <pre><code>def new
   @project = Project.new
  end
  </code></pre>