title: Ruby On Rails : Create csv-file and download as .zip-archive
body: <p>Hi I have created <code>csv file</code>, I want to download that file in <code>.zip-file</code> in my rails application. Please help me. I am not able do this how to add that file to zip and download that zip-file. How to render that file in rails.</p>
  
  <p>Below is the piece of code which I have tried,     </p>
  
  <pre><code>     # method to create csv
       def to_csv
         CSV.generate do |csv|
           #build csv format of document
         end
       end
  
       # controller action to download zip
       def zip_download
         zip = Zip::File.open('document.zip', Zip::File::CREATE) do |zipfile|
                 @documents.each do |document|
                  # document.to_csv how to add this file .zip
                 end
               end
         send_data zip, filename: "abc.zip", type: 'application/zip'
       end
  </code></pre>