Download .html file instead of opening in browser with link_to

I have this code:

<%= link_to "download", "https://region.amazonaws.com/bucket/file.html" %>

I want to download this file as it is, instead of opening it in browser. Any ideas? Thanks!

Read here about possible options. In short:

  • server should respond with correct response headers in order for browser to recognise the file should be downloaded (and not displayed)

  • use HTML5 <a href="file.html" download="myfile.html"> attribute (not supported in IE and Safari)

2 Likes

Thanks Lenart, that helped.