Setting header in views?

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
    #send it to the browser
    send_data csv_string,
      :type => 'text/csv; charset=iso-8859-1; header=present',
      :disposition => "attachment; filename=#{'data'}.csv"

i wanted to contain the “display codes” inside a view so i tried using
respond_to do |format|
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 ?

stubmbled across this message right after looking at this message.

Maybe it will help you. Good Luck!

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