title: Rails 3: How to respond_with csv without having a template file?
body: <p>I have an object that has a <code>to_csv</code> method and I want to pass it to <code>respond_with</code> to render csv from my controller.  My code looks like this:</p>
  
  <pre><code>class Admin::ReportsController &lt; AdminController
  
    respond_to :csv
  
    def trips
      respond_with TripReport.new
    end
  end
  </code></pre>
  
  <p>Instances of TripReport have a to_csv method.</p>
  
  <p>When I make a request to that action I get the following error:</p>
  
  <pre><code>ActionView::MissingTemplate (Missing template admin/reports/trips with {:formats=&gt;[:csv], :handlers=&gt;[:erb, :builder, :rjs, :rhtml, :rxml], :locale=&gt;[:en, :en]} in view paths
  </code></pre>
  
  <p>So it looks like the controller is looking for a template file to render.  How can I get around this?</p>
  
  <p>I'd rather the csv format responded in a similar way to json, so it calls <code>to_csv</code> on the object and just renders the output, is this possible?</p>