Force output to download as a file in Rails
1 2 response.headers['Content-Type'] = 'text/csv' # I've also seen this for CSV files: 'text/csv; charset=iso-8859-1; header=present' 3 response.headers['Content-Disposition'] = 'attachment; filename=thefile.csv'