I have the following in my .erb:
<%= link_to 'Download PDF', planners_download_pdf_url %>
I have the following method to respond:
def download_pdf
send_file(
"#{Rails.root}/Thing/ex/example.xls",
filename: "mything.xls",
type: "application/xls"
)
end
My routes has:
get '/planners/download_pdf'
When I click my link, the method does get invoked. My problem is that is doesn't download to the browser. Instead, it takes the tab I have open in the browser and dumps the file as HTML. Like... have you ever seen an Excel file opened in notepad? It does that. See below:
How do I get this to instead download the file?
[https://stackoverflow.com/questions/13164063/file-download-link-in-rails](https://stackoverflow.com/questions/13164063/file-download-link-in-rails) – Jim Tebstone Aug 04 '17 at 15:07