I want to send the file file.txt from my Rails controller using send_file, and then delete the folder containing it.
send_file("#{Rails.root}/public/folder/file.txt")
system("rm -rf #{Rails.root}/public/folder")
When I tried this, file.txt was correctly sent, file.txt was correctly deleted, but somehow folder was not deleted.
How can I make it delete folder?
Try to delete the folder directly with the native ruby method instead of a system command:
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_dir