title: ArgumentError File Upload / Import Using Roo
body: <p>I am passing the file object into this. 
  Controller:</p>
  
  <pre><code>RejectLoadsUpload.import(params[:file])
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>def import(file)
    parse_file(file)
  end
  
  def parse_file(filename)
    #filename is absolute path
    posts = parse_csv(filename)
    posts.keep_if {|x| x.keys.include? "type"}
    posts.each do |post|
      record = build_record(post)
      #Resque.enqueue(LoadPoster, record)
      #ToTest this uncomment the following line and comment out the above line
      RejectLoads.create(record)
    end
  
    @log.info "Finished parsing #{filename}..."
  
    #File.delete(filename)
    #if File.exists?(filename)
    #  @log.error "File #{filename} was not deleted successfully."
    #end
  end
  
  # Takes in a file name that is a path to a CSV
  #  returns a posts which is an array of array of the parsed file
  def parse_csv(filename)
    workbook = Roo::Spreadsheet.open(filename.path.to_s, extension: :xlsx)
    workbook.default_sheet = workbook.sheets[0]
    header = workbook.row(1)
    raise EdiLoadsFileEmpty if header.nil?
    posts = []
    (2..workbook.last_row).each do |i|
      post = Hash[header.zip (workbook.row(i))]
      posts.push post
    end
    posts
  end
  </code></pre>
  
  <p>I have tried:</p>
  
  <pre><code>workbook = Roo::Spreadsheet.open(filename, extension: :xlsx)
  workbook = Roo::Spreadsheet.open(filename.path, extension: :xlsx)
  workbook = Roo::Spreadsheet.open(filename.tempfile.path.to_s, extension: :xlsx)
  </code></pre>
  
  <p>With and without the extension</p>
  
  <p>Also been trying to use <code>Roo::Excelx.new</code> As well with no luck</p>
  
  <p>But i am getting an argument error when it gets to: </p>
  
  <p><code>header = workbook.row(1)</code></p>
  
  <p>I believe that the error is in the way that i am opening the file.</p>
  
  <p><a href="https://i.stack.imgur.com/acsBG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/acsBG.jpg" alt="enter image description here"></a></p>
  
  <pre><code>Started POST "/rejects/import" for 192.168.1.121 at 2015-07-28 13:41:36 -0500
  Processing by RejectsController#import as HTML
  Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"8zv12AJ4p1cnnWv64c8/N/Nhh0TaMBNZaRzpBgMWcn0=", "file"=&gt;#&lt;ActionDispatch::Http::UploadedFile:0xb4cf00a8 @original_filename="EDIORD@REJ (4).xlsx", @content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"EDIORD@REJ (4).xlsx\"\r\nContent-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n", @tempfile=#&lt;File:/tmp/RackMultipart20150728-3506-18nzbha&gt;&gt;, "commit"=&gt;"Import"}
          Completed 500 Internal Server Error in 168ms
  
  ArgumentError (ArgumentError):
      app/models/service_objects/reject_loads_upload.rb:34:in `parse_csv'
    app/models/service_objects/reject_loads_upload.rb:12:in `parse_file'
    app/models/service_objects/reject_loads_upload.rb:7:in `import'
  app/controllers/rejects_controller.rb:13:in `import'
  
  
    Rendered /usr/local/rvm/gems/ruby-1.9.3-p551@loadmax/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (3.9ms)
    Rendered /usr/local/rvm/gems/ruby-1.9.3-p551@loadmax/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.5ms)
    Rendered /usr/local/rvm/gems/ruby-1.9.3-p551@loadmax/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (13.4ms)
  </code></pre>
  
  <p>Logs Nothing Here:</p>
  
  <pre><code>  workbook = Roo::Spreadsheet.open(filename, extension: :xlsx)
    @log.info workbook
    # =&gt; &lt;#Roo::Excelx:517603520 @tmpdirs @tmpdir @filename @comments_files @rels_files @sheet_files @workbook @sheet_names @sheets @styles @shared_strings @sheets_by_name @options @cell @cell_type @cells_read @first_row @last_row @first_column @last_column @header_line&gt;
    workbook.default_sheet = workbook.sheets[0]
    @log.info workbook.default_sheet
    # =&gt; Sheet1
    @log.info workbook.row(1)  &lt;--- Stack errors here now...
    # =&gt; (Blank)   
    header = workbook.row(1)
  </code></pre>