i'm using rails 3.2.22 and ruby 2.2.
i'm creating a text file and i want to send that for download using send_to. My code works as expected but every time i hit the action one local copy of the file is getting created in my application root folder. I dont want this and file should directly go to download folder. Am i doing anything wrong ??
def save_trunk_logs
data = ""
file = "test.txt"
trunk_logs = some data
File.open(file, "w") do |aFile|
aFile.write("Trunk Name : #{trunk_name}\n")
aFile.write("*"*100)
aFile.write("\n")
aFile.write("Time Stamp"+"\t"+"Log Message\n")
trunk_logs.each do |msg|
text =format_log_messages msg
data << "#{data}\n"
end
end
send_file file, :type => 'application/text; charset=UTF-8', :disposition => 'attachment'
end
Any help is appreciated.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire