I have recently upgraded my application to Rails 5 and my downloads stopped working. When I click download button, browser hangs and nothing happens.
class DownloadsController < ApplicationController
  def download
    send_file(
      "#{Rails.root}/public/file.rtf",
      filename: "file.rtf",
      type: :rtf,
      disposition: "attachment"
    )
  end
end
I have rtf mimetype
Mime::Type.register "text/richtext", :rtf
Logs showing that everything is ok
Sent file /home/deploy/app/releases/20160518213049/public/file.rtf (0.4ms)
I, [2016-05-18T17:34:48.435946 #20202]  INFO -- : [d02e8ea3-53da-440d-b3b1-cc6bfd6524dc] Completed 200 OK in 17ms (ActiveRecord: 4.4ms)
                As it was detailed in above comments, the solution is to disable the turbolinks for link_to. This can be done, for Turbolinks 5, as it is described  here by using data-turbolinks="false" 
<%= link_to "Foo", new_foo_path(@foo), data: { turbolinks: false } %>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With