> 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.
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?