Download csv

Hi, in my application i want to develop a code where when i click on
download link , csv file get downloaded to client side.
so for this i put

Download the group template (requires Excel).
(download_template.csv
is my public dir.)
code in rhtml.its working correctly for IE but in Mozilla it directly
open in browser instade that it ask for pop up, how should i do it?

http://teapoci.blogspot.com/2008/05/linktofile-call-file-from-rhtml-or.html

reinhart

On May 20, 2008, at 3:53 AM, Sunny B. wrote:

open in browser instade that it ask for pop up, how should i do it?

http://api.rubyonrails.org/classes/ActionController/Streaming.html#M000228

 send_file( 'public/download_template.csv',
            :type => 'text/csv',
            :disposition => 'attachment',
            :stream => true,
            :filename => 'download_template.csv' )

Except for :type, the other options are the defaults.

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

Rob B. wrote:

On May 20, 2008, at 3:53 AM, Sunny B. wrote:

open in browser instade that it ask for pop up, how should i do it?

http://api.rubyonrails.org/classes/ActionController/Streaming.html#M000228

 send_file( 'public/download_template.csv',
            :type => 'text/csv',
            :disposition => 'attachment',
            :stream => true,
            :filename => 'download_template.csv' )

Except for :type, the other options are the defaults.

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

This code is OK ,but where to put this code in rhtml ya in separate
method.
if i am write new methos it give template error (rhtml missing),and in
rhtml how i used it?

On May 21, 2008, at 1:01 AM, Sunny B. wrote:

           :stream => true,

method.
if i am write new methos it give template error (rhtml missing),and in
rhtml how i used it?

As you could determine from the documentation link (if not from the
documentation itself), this is part of ActionController. It goes into
an action method and takes the place of a render or redirect.

Typically, you use send_file (or send_data) when the file is not
visible in the standard directory structure (i.e., not under public/)
or when you want to base the response on some calculation or property
of the request.

-Rob

P.S. There are many who see these messages as email and not in the
forum. Please do not post the same question in multiple places.

Rob B. http://agileconsultingllc.com
[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs