I created a file in the tmp directory with the following controller code:
def download
file_path = "#{RAILS_ROOT}/tmp/downloads/xxx.html"
data = render_to_string( :action => :show, :layout => nil )
File.open(file_path, "w"){|f| f << data }
flash[:notice] = "saved to #{file_path}"
end
This creates the file that I need in the tmp directory, and I want the user to download this file.
On my local machine, the file is saved to a path, for example:
/Users/xxxx/Documents/Sites/xxxx/Website/htdocs/tmp/downloads/xxxx.html
And on a live server, this URL will be completely different.
I was wondering how to get the user to download this xxxx.html?
PS If I put ...
redirect_to file_path
... on the controller, he just gives me a route that was not found.
Greetings.
source
share