title: Creating multiple entries on one model - Ruby on Rails (non nested)
body: <p>I am having a difficult time finding information on this but think the solution is a simple one. In short, I need to have the ability to add multiple entries to one model at one time. The user story goes like this: User selects "Add New" and is directed to the page where they can add simply ONE entry or select a drop down of the desired entries they want to add.</p>
  
  <p>All the posts I see have information about doing this with objects that are nested but I am just using one model. Do I need to follow the same protocol? Is there a simpler way? Am I just searching for the wrong terminology since being new to Ruby? </p>
  
  <p>The basic application looks like this:</p>
  
  <p>ticket_controller.rb</p>
  
  <pre><code>def new
     @ticket = Ticket.new
  end
  def create
  tnum = gets.chomp
  tnum.times do Ticket.new(ticket_params)
  
  respond_to do |format|
    if @ticket.save
      format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }
      format.json { render action: 'show', status: :created, location: @ticket }
    else
      format.html { render action: 'new' }
      format.json { render json: @ticket.errors, status: :unprocessable_entity }
    end
  end
  end
  </code></pre>
  
  <p>new.html.erb</p>
  
  <pre><code>&lt;h1&gt;New ticket&lt;/h1&gt;
  
  &lt;%= render 'form' %&gt;
  
  &lt;%= link_to 'Back', tickets_path %&gt;
  </code></pre>
  
  <p>I have looked throughout the site and just think I am missing something! Thanks for pointing me in the direction needed. </p>
  
  <p>_form.html.erb</p>
  
  <pre><code>&lt;%= form_for(@ticket) do |f| %&gt;
  &lt;% tnum.times do |index|%&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :type %&gt;&lt;br&gt;
      &lt;%= f.text_field :type %&gt;
    &lt;/div&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :amount %&gt;&lt;br&gt;
      &lt;%= f.text_field :amount %&gt;
    &lt;/div&gt;
    &lt;% end %&gt;
    &lt;div class="actions"&gt;
      &lt;%= f.submit %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>