I have a link_to Rails helper that downloads a wallpaper when clicked. But the image is loading in the browser instead of being downloaded immediately.
<%
Rails 3 / 4:
in routes:
get "home/download_pdf"
in controller:
def download_pdf send_file( "#{Rails.root}/public/your_file.pdf", filename: "your_custom_file_name.pdf", type: "application/pdf" ) end
in view:
<%= link_to 'Download PDF', home_download_pdf_url %>