Forum: Ruby on Rails RE: Output non-HTML (CSV) from Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2006-01-11 22:38
(Received via mailing list)
Bakki K. wrote:
> Have you tried send_data or send_file which are " Methods for sending
> files and streams to the browser instead of rendering." I have used
> send_data to send and image to the browser. Check out my howto ...
>
>
http://wiki.rubyonrails.com/rails/pages/HowtoSecur...

Bakki,

Very nice! This seems to be the ideal way to solve the problem.

For some reason when rendering through the view (as Alex Y.
suggested) I was getting ~6500 whitespace lines preceeding the start of
my CSV data.

But using 'send_data' in the controller seems to have solved that.

And I also just discovered how to direct the filename of the
downloadable attachment file with an addition to the Content-Disposition
header:

  send_data csv_data, :type => 'text/csv', :disposition => 'attachment;
filename=output.csv'

Thank you Bakki, Alex, and Adam!

   Matt

--
Matt C. Wagner
Information Security Analyst

Network Intrusion Detection
Security Operations Center
Corporate Information Security
Wells Fargo Bank
This topic is locked and can not be replied to.