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 <a href="/download_template.csv" style="color:#000000"> Download the group template (requires Excel).</a>(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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
http://teapoci.blogspot.com/2008/05/linktofile-call-file-from-rhtml-or.html reinhart -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On May 20, 2008, at 3:53 AM, Sunny Bogawat wrote:> > 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 > <a href="/download_template.csv" style="color:#000000"> > Download the group template (requires Excel).</ > a>(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://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 Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn wrote:> On May 20, 2008, at 3:53 AM, Sunny Bogawat 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 Biedenharn http://agileconsultingllc.com > Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.orgThis 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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On May 21, 2008, at 1:01 AM, Sunny Bogawat wrote:> Rob Biedenharn wrote: >> On May 20, 2008, at 3:53 AM, Sunny Bogawat 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 Biedenharn http://agileconsultingllc.com >> Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org > > 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? > --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 Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---