Creating a tar file for download


I have an action on my controller named download which creates a tar
file and then sends the file (via send_file) to the user. Its working
but I will like to delete the file once it is sent. The tar file
should be temporary and only available for download and then deleted
from the server. Any idea on how to do this?

def download
@app = App.find params[:id]
system('cd ‘[email protected]+’ && tar -cf ‘[email protected]+’.tar
send_file $global_path+"#{}/#{}.tar"

Basically I just want to be able to delete the file one it is
download. Any ideas?