Forum: Ruby on Rails setting header in views?

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.
Lin W. (Guest)
on 2009-01-14 06:50
currently iam using FasterCSV to render csv pages

format.csv do
        csv_string = FasterCSV.generate do |csv|
          # header row
          csv << @query_result[0].keys

          @query_result.each do |x|
            csv << x.values
          end
        end
        #send it to the browser
        send_data csv_string,
          :type => 'text/csv; charset=iso-8859-1; header=present',
          :disposition => "attachment; filename=#{'data'}.csv"
      end

i wanted to contain the "display codes" inside a view so i tried using
respond_to do |format|
   format.csv
and having a matching show.csv.erb

but i cant set the header information
-> send_data csv_string,
          :type => 'text/csv; charset=iso-8859-1; header=present',
          :disposition => "attachment; filename=#{'data'}.csv"
inside the view itself

anyway to do it ?
engineerDave (Guest)
on 2009-03-07 14:32
(Received via mailing list)
stubmbled across this message right after looking at this message.

http://groups.google.com/group/rubyonrails-talk/br...

Maybe it will help you. Good Luck!
This topic is locked and can not be replied to.