Hi, I am quite new to Ruby and Rails, although I have cracked most of my puzzles by googling and trying I just can''t get this one to get going for me. Here is my problem: I am trying to cough up a nice text/csv file from my browser and would like to set this: Content-type: text/csv Content-disposition: attachment; filename="the_file.csv" in my HTTP response header, but so far I haven''t found any ''''tricks'''' to achieve the ''Content-disposition'' part. Any help would be dearly appreciated. Kind regards, Hartog. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
in class ApplicationController < ActionController::Base before_filter :set_headers private def set_headers @headers["Content-Type"] = "text/csv" @headers["Content-disposition"] = ''attachment; filename="the_file.csv"'' end end very easy :) On Feb 28, 3:32 pm, "hartog" <har...-NNTGXQXcYNJl57MIdRCFDg@public.gmane.org> wrote:> Hi, > > I am quite new to Ruby and Rails, although I have cracked most of my > puzzles by googling and trying I just can''t get this one to get going > for me. > > Here is my problem: > > I am trying to cough up a nice text/csv file from my browser and would > like to set this: > > Content-type: text/csv > Content-disposition: attachment; filename="the_file.csv" > > in my HTTP response header, but so far I haven''t found any ''''tricks'''' > to achieve the ''Content-disposition'' part. > > Any help would be dearly appreciated. > > Kind regards, > Hartog.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hartog C. de Mik
2007-Feb-28 15:00 UTC
Re: Re: Getting content-disposition in the HTTP response headers.
On Wed, Feb 28, 2007 at 06:36:34AM -0800, S2 wrote:> On Feb 28, 3:32 pm, "hartog" <har...-NNTGXQXcYNJl57MIdRCFDg@public.gmane.org> wrote: > > Hi, > > > > I am quite new to Ruby and Rails, although I have cracked most of my > > puzzles by googling and trying I just can''t get this one to get going > > for me. > > > > Here is my problem: > > > > I am trying to cough up a nice text/csv file from my browser and would > > like to set this: > > > > Content-type: text/csv > > Content-disposition: attachment; filename="the_file.csv" > > > > in my HTTP response header, but so far I haven''t found any ''''tricks'''' > > to achieve the ''Content-disposition'' part. > > > > Any help would be dearly appreciated. > > in > > class ApplicationController < ActionController::Base > before_filter :set_headers > > private > def set_headers > @headers["Content-Type"] = "text/csv" > @headers["Content-disposition"] = ''attachment; > filename="the_file.csv"'' > end > endThank you!> very easy :)Once you how, yes indeed. :-> I do however think that render() (from: ApplicationController::Base) should allow for a '':disposition'' option as well. Where should I go for such a feature request? Grtz, Hartog --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I have a problem that may be resolved with this, if I understand it correctly. I have one controller/view that keeps rendering as text/ plain ... that''s how the headers come back from the server. My content type is set correctly in the header in my layout file. Can I do something similar in my specific controller to force it to render as text/html instead of text/plain? Thanks Zeff On Feb 28, 10:00 am, "Hartog C. de Mik" <har...-NNTGXQXcYNJl57MIdRCFDg@public.gmane.org> wrote:> On Wed, Feb 28, 2007 at 06:36:34AM -0800, S2 wrote: > > On Feb 28, 3:32 pm, "hartog" <har...-NNTGXQXcYNJl57MIdRCFDg@public.gmane.org> wrote: > > > Hi, > > > > I am quite new to Ruby and Rails, although I have cracked most of my > > > puzzles by googling and trying I just can''t get this one to get going > > > for me. > > > > Here is my problem: > > > > I am trying to cough up a nice text/csv file from my browser and would > > > like to set this: > > > > Content-type: text/csv > > > Content-disposition: attachment; filename="the_file.csv" > > > > in my HTTP response header, but so far I haven''t found any ''''tricks'''' > > > to achieve the ''Content-disposition'' part. > > > > Any help would be dearly appreciated. > > > in > > > class ApplicationController < ActionController::Base > > before_filter :set_headers > > > private > > def set_headers > > @headers["Content-Type"] = "text/csv" > > @headers["Content-disposition"] = ''attachment; > > filename="the_file.csv"'' > > end > > end > > Thank you! > > > very easy :) > > Once you how, yes indeed. :-> > > I do however think that render() (from: ApplicationController::Base) > should allow for a '':disposition'' option as well. > > Where should I go for such a feature request? > > Grtz, > Hartog--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeremy Kemper
2007-Feb-28 21:07 UTC
Re: Getting content-disposition in the HTTP response headers.
On 2/28/07, Hartog C. de Mik <hartog-NNTGXQXcYNJl57MIdRCFDg@public.gmane.org> wrote:> > > very easy :) > > Once you how, yes indeed. :-> > > I do however think that render() (from: ApplicationController::Base) > should allow for a '':disposition'' option as well.send_data the_csv_data, :filename => ''data.csv'', :type => ''text/csv'' http://api.rubyonrails.org/classes/ActionController/Streaming.html#M000092 Where should I go for such a feature request? Submit requests, bugs, and patches at http://dev.rubyonrails.org/ jeremy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hartog wrote:> Content-type: text/csv > Content-disposition: attachment; filename="the_file.csv"http://www.rubyinside.com/railstips/tag/send_file -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---