How come this works to render :json with no template, but not to render :csv?
in my datapoints_controller's index method:
respond_to do |format|
format.json { render :json => @goal.datapoints.all }
format.csv { render :csv => @goal.datapoints.all }
end
Pointing my browser to /datapoints.json renders the collection as a json string on screen. Pointing it to /datapoints.csv gives an error:
Template Missing: with {:locale=>[:en, :en], :formats=>[:csv],
:handlers=>[:rhtml, :rxml, :erb, :builder, :rjs]}
An instance of Datapoint responds to to_csv, but even if I manually map it into csv format and render it as text it gives a Template Missing error, so, e.g. I tried something like this:
format.csv { render @goal.datapoints.map{|d| d.to_csv }.join "\n" }