title: is there a rails method to loop through each line of uploaded file? "each_line" is an IO method but it's not working
body: <p>I'm attempting to upload a csv file, parse it, and spit out a file for S3 or just pass to view.  I use a file_field_tag to upload the csv.  I thought file_field_tag passes an object that is a subclass of IO and would have all ruby IO methods such as "each_line".  I can call "read" on the object (method of IO class) but not "each_line"... so how can I iterate over each line of a file_field_tag upload? </p>
  
  <p>create method of my controller as:</p>
  
  <pre><code>@csv_file = params[:csv_file]
  </code></pre>
  
  <p>My show view which throws a no "each_line" method error:</p>
  
  <pre><code>&lt;% @csv_file.each_line do |line| %&gt;
  &lt;%= line %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Yet I can use</p>
  
  <pre><code>&lt;%= @csv_file.read(100) %&gt;
  </code></pre>
  
  <p>I'm really confused what methods a file_field_tag upload params[] has... each_line, gets don't work... I can't seem to find a list of what I can use.</p>
  
  <p><strong>EDIT</strong>
  I worked around this by doing:</p>
  
  <pre><code>@csv_file = params[:csv_file].read.to_s
  </code></pre>
  
  <p>then iterated through with:</p>
  
  <pre><code>&lt;% @sp_file.each_line do |line| %&gt;
  &lt;%= line %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p><strong>EDIT 2</strong>
  The file being uploaded has repeats the header after lines which don't contain a comma (don't ask)... So I find lines without a comma and call .gets (in my rb script independent of rails).  Unfortunately I get an error about gets being a private method I can't call.  Which goes back to my initial issue being.  Aren't files a sub class of IO with IO methods like read_lines &amp; gets?</p>
  
  <pre><code>        @file_out = []
          @file_in.each_line do |line|
              case line
              when /^[^,]+$/
                  @comp = line.to_s.strip
                  comp_header = @file_in.gets.strip.split('')
  
                  @file_out.push(@comp)
              end
          end
  </code></pre>