0

I am trying to export data from a rails app and have the user download a CSV file when they hit a certain controller#action.

I found this article and used the sample code exactly. http://oldwiki.rubyonrails.org/rails/pages/HowtoExportDataAsCSV

I do, in fact, get a CSV file, but within it, there is only one line of output:

#<Proc:0x00000001032c6808@/PATH_CRAP/app/controllers/reports_controller.rb:35>

Here are lines 35, 36 and 37 from the file in question.

  render :text => Proc.new { |response, output|
    csv = FasterCSV.new(output, :row_sep => "\r\n") 
    yield csv

I am using Rails 3.0.5 and added the following to my Gemfile:

gem 'fastercsv'

What gives?

NJ.
  • 2,155
  • 6
  • 26
  • 35

1 Answers1

1

render :text => proc {...} does not work in Rails 3. For the replacement, see this question.

Community
  • 1
  • 1
John
  • 29,546
  • 11
  • 78
  • 79
  • Thanks! I haven't been able to test this. I will tonight and will respond or, at least, check the green-check mark. – NJ. Mar 30 '11 at 20:25