dimanche 19 juin 2016

miss template when respond CSV

I have a action to download file csv, but when click error missing template

Code in my action

def export 
    respond_to do |format|
      format.html
      format.csv { send_data UserDetail.order('id desc').first(20).to_csv }
    end
  end

In my view:

= link_to "Export CSV", export_call_center_user_details_path(format: "csv"), :class => "btn btn-default"

error:

Processing by CallCenter::UserDetailsController#export as CSV Completed 500 Internal Server Error in 5ms

A ActionView::MissingTemplate occurred in user_details#export:

Missing template call_center/user_details/export, application/export with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee, :haml]}.

When i try remove line format.html so error:

Completed 406 Not Acceptable in 4ms (ActiveRecord: 0.3ms)

How to fix error above?

Aucun commentaire:

Enregistrer un commentaire