Rails 3: How to respond_with csv without having a template file?

后端 未结 6 2315
时光取名叫无心
时光取名叫无心 2020-12-28 17:29

I have an object that has a to_csv method and I want to pass it to respond_with to render csv from my controller. My code looks like this:

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-28 17:51

    I ran into what I would guess is a similar problem to what you were experiencing, Oliver. I realized that in my routes file I was using resource instead of resources. I do not know if you have other actions in your Admin::ReportsController class or what your routes file looks like, but this is how I would tackle the problem if Reports has the standard REST actions.

    scope :module => 'Admin' do
      resources :reports do
        get :trips, :on => :collection
      end
    end
    

    If that does not apply, run rake routes to see if your routes are configured correctly.

提交回复
热议问题