To stream a CSV file in a controller action: headers['Content-Type'] = 'text/plain' headers['Content-disposition'] = "attachment; filename=\"#{filename}\";" headers['Last-Modified'] = Time.zone.now.httpdate headers['X-Accel-Buffering'] = 'no' headers['Cache-Control'] = 'no-cache' headers.delete('Content-Length') self.response_body = Enumerator.new do |csv| csv << "Name;Age\r\n" cats.each do |cat| csv << "#{cat.name};#{cat.age}\r\n" end end self.response_body must respond to each.