Advertisement
rodrigoAIS

Untitled

Feb 10th, 2017
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.85 KB | None | 0 0
  1. def create
  2.     if params[:model] != nil
  3.       zip_information = CloneDatabaseService.all_objects(params)
  4.       unless CloneDatabase.last.nil?
  5.         all_database_tables = return_all_database_tables
  6.         zip_data = CloneDatabaseService.build_zip(zip_information, all_database_tables)
  7.         model_name = CloneDatabase.last.start.strftime("%Y/%m/%d %H:%m:%S").to_s
  8.  
  9.         # By default, temp files are 0600,
  10.         # so this line might be needed depending on your configuration:
  11.         # XXX: Deixa o rails gerenciar o download do arquivo
  12.         # send_data(zip_data, type: 'application/zip', filename: "#{model_name}.zip")
  13.         send_file(zip_data.path, type: 'application/zip', filename: "#{model_name}.zip")
  14.         zip_data.unlink
  15.         # XXX: Remove arquivo
  16.         # zip_data.close
  17.         # zip_data.unlink
  18.  
  19.       end
  20.     end
  21.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement