title: Creating multiple records for a model in a single view in Rails
body: <p>I have a model named <code>Book</code>, and I want to adjust the standard <code>Book#new</code> to show the fields for 10 books, so that 10 can be created at once instead of just one.</p>
  
  <p>I looked at <a href="https://stackoverflow.com/questions/13658248/rails-3-create-view-to-insert-multiple-records">this question</a> and found that I could repeat the form if I added <code>10.times</code> to my form.  However, I didn't do it correctly because a new record is saved, but with all fields null.</p>
  
  <p>What I want to do is to:</p>
  
  <ol>
  <li>Allow the user to enter up to 10 books at one-time and then save them</li>
  <li>If the user populates only three book records, create only three (and ignore the seven records in the form others with null values)</li>
  </ol>
  
  <p>My view:</p>
  
  <pre><code>&lt;%= simple_form_for(@book) do |f| %&gt;
    &lt;%= f.error_notification %&gt;
    &lt;% 10.times do |index|%&gt;
      &lt;%= f.input :title %&gt;
      &lt;%= f.association :book_category %&gt;   
    &lt;% end %&gt;
  
    &lt;%= f.submit %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>My controller is unchanged from the scaffolding code:</p>
  
  <pre><code>def new
    @book = Book.new
  end
  
  def create
    @book = Book.new(params[:book])
  end
  </code></pre>