Browse files

refactored/updated handling of content disposition header

  • Loading branch information...
1 parent 7073d1e commit 29074ffed2c02a89e6cd1c7e73f091e3e31630bd @adamhunter adamhunter committed Feb 5, 2013
Showing with 6 additions and 2 deletions.
  1. +6 −2 app/controllers/dossier/reports_controller.rb
View
8 app/controllers/dossier/reports_controller.rb
@@ -18,12 +18,12 @@ def show
end
format.csv do
- headers["Content-Disposition"] = %[attachment;filename=#{params[:report]}-report_#{Time.now.strftime('%m-%d-%Y-%H%M%S')}.csv]
+ set_content_disposition!
self.response_body = StreamCSV.new(report.raw_results.arrays)
end
format.xls do
- headers["Content-Disposition"] = %[attachment;filename=#{params[:report]}-report_#{Time.now.strftime('%m-%d-%Y-%H%M%S')}.xls]
+ set_content_disposition!
self.response_body = Xls.new(report.raw_results.arrays)
end
end
@@ -35,5 +35,9 @@ def report_class
"#{params[:report].split('_').map(&:capitalize).join}Report".constantize
end
+ def set_content_disposition!
+ headers["Content-Disposition"] = %[attachment;filename=#{params[:report]}-report_#{Time.now.strftime('%m-%d-%Y_%H-%M-%S')}.#{params[:format]}]
+ end
+
end
end

0 comments on commit 29074ff

Please sign in to comment.