title: Upload CSV file in Rails and process records to display on page without saving file?
body: <p>I am in the process of learning Rails and am trying to create a file upload page to process CSV data without any use of my database or model. I am also trying to avoid using any gems such as Paperclip or Carrier-wave.</p>
  
  <p>I have made some progress, but for some reason, my code is not working. I don't get the records that are in the CSV file displayed on the <code>import.html.erb page.</code></p>
  
  <p>When I click the upload button on my page: localhost:3000/upload, it redirects me properly to the expected page after submission, but the rows from file don't appear. </p>
  
  <p>Does anyone have a clue why the page is not displaying the records from the CSV file?</p>
  
  <p>The upload file view (index.html.erb):</p>
  
  <pre><code>&lt;%= form_tag({:action =&gt; :import}, multipart: true) do %&gt;
    &lt;%= file_field_tag :file %&gt;
    &lt;%= submit_tag( "Import" ) %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>The controller (upload_controller.rb):</p>
  
  <pre><code>class UploadController &lt; ApplicationController
    def index
    end
  
    def import
      rowarray = Array.new
      myfile = params[:file]
  
      CSV.foreach(myfile.path) do |row|
        rowarray &lt;&lt; row
        @rowarraydisp = rowarray
      end
    end
  end
  </code></pre>
  
  <p>The result view (import.html.erb):</p>
  
  <pre><code>&lt;% @rowarraydisp.each do |row| %&gt;
    &lt;%= row %&gt;
  &lt;% end %&gt;
  &lt;h1&gt;File has been uploaded. Check&lt;/h1&gt;
  </code></pre>