When send_file is called, it's sending the file to the browser, but the browser is dumping the contents as plain-text on a new page instead of downloading the file. If I refresh that page, it then downloads the file as normal.
Route
get 'download' => 'qr_codes#download'
Controller
def download
path = Rails.root.join("events/active/#{params[:name]}/#{params[:batch]}/#{params[:file]}")
send_file(path, type: 'application/vnd.ms-excel', filename: params[:file])
end
View
<%= link_to 'Original Upload', download_path(name: @event_name,
batch: batch, file: batch_upload_filename(@event_name, batch)) %>
SOLUTION:
This ended up being a known issue with turbolinks. If using Turbolinks 5 like I am, the updated syntax is: data: { turbolinks: false }