title: Rails - Upload and parse multiple CSV files
body: <p>Im trying to upload and parse multiple CSV files. What I have so far:</p>
  
  <p>My View</p>
  
  <pre><code> &lt;h3&gt;Upload multiple files&lt;/h3&gt;  
    &lt;%= form_tag({:controller =&gt; "multi_uploader", :action =&gt; "import"}, :multipart =&gt; true) do %&gt;
      &lt;em&gt;Upload a tab-separated .txt file to generate new rating sets.&lt;/em&gt; &lt;hr/&gt;
      &lt;%= file_field_tag :file_1 %&gt;
       &lt;hr/&gt;
      &lt;%= file_field_tag :file_2 %&gt;
       &lt;hr/&gt;
      &lt;%= file_field_tag :file_3 %&gt;
       &lt;hr/&gt;
      &lt;%= file_field_tag :file_4 %&gt;
       &lt;hr/&gt;
      &lt;%= file_field_tag :file_5 %&gt;
       &lt;hr/&gt;
      &lt;%= file_field_tag :file_6 %&gt;
      &lt;hr/&gt;
      &lt;%= submit_tag "Import Data", :class =&gt; "btn btn-link"%&gt;
      &lt;% end %&gt;
  </code></pre>
  
  <p>My Controller:</p>
  
  <pre><code> def import
      unless params[:file_1].nil?
      file_1 = params[:file_1]
      RatingSet.multi_uploader(file_1)
    end
    unless params[:file_2].nil?
      file_2 = params[:file_2]
      RatingSet.multi_uploader(file_2)
    end
    unless params[:file_3].nil?
      file_3 = params[:file_3]
      RatingSet.multi_uploader(file_3)
    end
    unless params[:file_4].nil?
      file_4 = params[:file_4]
      RatingSet.multi_uploader(file_4)
    end
    unless params[:file_5].nil?
      file_5 = params[:file_5]
      RatingSet.multi_uploader(file_5)
    end
    unless params[:file_6].nil?
      file_6 = params[:file_6]
      RatingSet.multi_uploader(file_6)
    end
      redirect_to "/multi_uploader", :flash =&gt; { :notice =&gt; "Successfully Uploaded." }
    end
  </code></pre>
  
  <p>My Model method to import file:</p>
  
  <pre><code> def self.multi_uploader(file)
      upload = File.open(file.path)  
      #Parse file and save data to db. 
    end
  </code></pre>
  
  <p>In my <code>multi_uploader</code> method, I parse out a key (from the file) for which category the file is supposed to be uploaded to. Everything works as expected when I upload a single file, however if I upload multiple files, the contents of all files are being saved for to a single category, rather than multiple categories. Its as if all files are being treated as a single file, rather than n individual files. What can I change to upload each file individually? </p>