IE and PDF downloads over HTTPS in Rails
22 Apr 2011
So you have a controller that renders PDF’s, and all looks great. You decide to move from HTTP to HTTPS, and everything checks out. You deploy, and suddenly some of your users can’t see the PDF downloads anymore. These users are all running some version of IE - all the way from IE6 up to IE8.
The solution is to set your response headers as follows:
def show
inst = Model.find(params[:id])
response.headers['Content-Transfer-Encoding'] = 'binary'
response.headers['Content-Disposition'] = "attachment;filename=\"#{inst.id}.pdf\""
response.headers['Content-Description'] = 'File Transfer'
response.headers['Expires'] = '0'
response.headers['Pragma'] = 'public'
render # Render your pdf
end