title: Why does file.original_filename doesn't work in Ruby on Rails?
body: <p>i am implementing a few weeks now in Ruby. And what i want to do is read in a csv file, which i put then in a temporary file so i can access it in next views and manipulate the data. I have implemented everything like examples on the internet, but i always get the error : undefined method `original_filename' for nil:NilClass</p>
  
  <p>My code in my view is:</p>
  
  <pre><code>&lt;% form_for :dump, :url=&gt;{:controller=&gt;"project_importer", :action=&gt;"match"}, :html =&gt; { :multipart =&gt; true } do |f| -%&gt;
  &lt;table"&gt;
     &lt;tr&gt;
       &lt;td&gt;
        &lt;label for="dump_file"&gt;
          Select a CSV File :
        &lt;/label&gt;
       &lt;/td&gt;
       &lt;td &gt;
         &lt;%= f.file_field :file -%&gt;
       &lt;/td&gt;
     &lt;/tr&gt;
  
   &lt;/table&gt;
  </code></pre>
  
  <p>and then in my controller i have:</p>
  
  <pre><code>file = params[:file]
  
  
     @original_filename = file.original_filename
      tmpfile = Tempfile.new("redmine_user_importer")
      if tmpfile
        tmpfile.write(file.read)
        tmpfile.close
        tmpfilename = File.basename(tmpfile.path)
        if !$tmpfiles
          $tmpfiles = Hash.new
        end
        $tmpfiles[tmpfilename] = tmpfile
      else
        flash[:error] = "Cannot save import file."
        return
      end
  </code></pre>
  
  <p>I really don't know what i am doing wrong, i hope someone can help me out. The file param is not empty.</p>
  
  <p>Thanks in advance!</p>