Created
September 28, 2010 18:18
-
-
Save awd/601480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this responder allows the system to render a streaming proc | |
# rendering a proc was removed in Rails 3.0 | |
ActionController::Renderers.add :csv do |proc, options| | |
raise ArgumentError "CSV responder requires :filename" unless options.key? :filename | |
filename = options[:filename] | |
headers.merge!( | |
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', | |
'Content-Disposition' => "attachment; filename=\"#{filename}\"", | |
'Content-Transfer-Encoding' => 'binary' | |
) | |
self.content_type ||= Mime::CSV | |
self.response_body = proc | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment