Nothing like pleading to the world for help on a problem to quicken your 
mind!  I solved this.

First, I had to add a custom renderer in 
config/initializers/csv_renderer.rb:

require 'action_controller/metal/renderers'
> ActionController.add_renderer :csv do |csv, options|
>   self.response_body = csv.respond_to?(:to_csv) ? csv.to_csv(options) : csv
> end


And in order to tell the controller that it should respond to :csv I added 
the responders gem per my original post and added this to the top of the 
controller:

respond_to :csv


It works like a champ now.

Chris 

On Thursday, July 9, 2015 at 12:12:19 PM UTC-7, Chris McCann wrote:
>
> I'm nearly done porting a Rails 2.3 app to Rails 4.2, including a switch 
> to Postgres.  Yay!
>
> But I've bumped into an issue I can't seem to sort out with regard to 
> calling "send_data" in a controller to return a CSV file.  
>
> My previously functioning code now complains about a missing template:
>
> Missing template search_results_export/export_geo_search_results, 
>> application/export_geo_search_results with {:locale=>[:en], 
>> :formats=>[:csv], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, 
>> :coffee, :prawn, :prawn_dsl]}.
>
>
> The code isn't getting into the controller action where the CSV data is 
> generated, so it's something higher up in the stack.
>
> Responders were removed from Rails 4.2:
>
> respond_with and the class-level respond_to methods have been extracted 
>> to the responders gem. To use them, simply add gem 'responders', '~> 2.0' 
>> to your Gemfile.
>
>
> I've added the responders gem but still no dice.
>
> Anyone have words of wisdom?  Do I need to add a custom Renderer?
>
> Chris
>

-- 
-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
--- 
You received this message because you are subscribed to the Google Groups "SD 
Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to