Skip to content

Instantly share code, notes, and snippets.

@awd
Created October 12, 2010 19:29
Show Gist options
  • Save awd/622764 to your computer and use it in GitHub Desktop.
Save awd/622764 to your computer and use it in GitHub Desktop.
# this renderer allows the system to render progressively generated content
# rendering a proc was removed in Rails 3.0
ActionController::Renderers.add :csv do |detailed_report, options|
filename = detailed_report.to_filename
headers['Cache-Control'] = 'must-revalidate, post-check=0, pre-check=0'
headers['Content-Disposition'] = "attachment; filename=#{filename}"
headers['Content-Type'] = 'text/csv'
headers['Content-Transfer-Encoding'] = 'binary'
self.response_body = detailed_report
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment