I’m wondering if it’s possible to do this in Rails:
Have a link on the webpage. When the user clicks on the link, the controller generates a file dynamically (say, a text file that contains a single random number between 1 and 10), and the file is downloaded onto the user’s computer. The file might be temporarily stored on the server, but it shouldn’t be permanently there.
Use
send_datain the controller:If you already have the file on the server, you can use
send_fileinsteadhttp://api.rubyonrails.org/classes/ActionController/DataStreaming.html#method-i-send_data