title: Using Tempfile to create a zip file in rails
body: <p>I want to create a temporary .zip in rails. For creating zip file I am using <code>rubyzip</code> gem. </p>
  
  <p>Currently I am doing this:</p>
  
  <pre><code>zfname = Tempfile.new(['somename','.zip'], Rails.root.to_s + '/tmp/')
  Zip::ZipFile.open(zfname.path, Zip::ZipFile::CREATE) do |zipfile|
    zipfile.add(file, basepath + file)
  end
  </code></pre>
  
  <p>This generates following error:</p>
  
  <pre><code>Zip::ZipError: Zip end of central directory signature not found
  </code></pre>
  
  <p>Is it possible to use <code>Tempfile</code> for zip? If yes, what is wrong here?</p>