2017-05-11 5 views
0

私のアプリケーションでは、ExcelとPDFを添付する必要がありますが、エラーが発生しています。以下はRoRでExcelとPdfが動作しない

ActionView::MissingTemplate: Missing template self_services/show, application/show with {:locale=>[:en], :formats=>[:xls], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :axlsx, :jbuilder]}. Searched in: 

私のコントローラのコードです -

def show_self_datewise_attendance 
    @from = params[:employee][:from] 
    @to = params[:employee][:to] 
    @employee_attendances = EmployeeAttendance.where(day: @[email protected]_date,employee_id: current_user.employee_id) 

    respond_to do |format| 
     format.js 
     format.xls {render template: 'self_services/datewise_attendance_report_xls.xls.erb'} 
     format.html 
     format.pdf do 
     render pdf: 'datewise_attendance_report_pdf', 
       layout: 'pdf.html', 
       orientation: 'Landscape', 
       template: 'self_services/datewise_attendance_report_pdf.pdf.erb', 
       # show_as_html: params[:debug].present?, 
       :page_height  => 1000, 
       :dpi    => '300', 
       :margin   => {:top => 10, # default 10 (mm) 
          :bottom => 10, 
          :left => 20, 
          :right => 20}, 
       :show_as_html => params[:debug].present? 
      end 
     end 
    end 
+0

この希望を試してみてください。http://stackoverflow.com/questions/9561000/actionviewmissingtemplate-missing-template –

+0

これまでの解決策はありましたか? –

+0

まだ@AniketShivamTiwari –

答えて

0

はあなたのself_services/datewise_attendance_report_xls.xls.erbは、実際にどのようなものが見えますか?投稿したエラーによると、ファイルが見つかりません。私はこれまでに問題なくhttp://railscasts.com/episodes/362-exporting-csv-and-excelを成功裏に追跡しました。

+0

datewise_attendance_report_xls.xls.erbは、self_serviceテーブルにあるExcelページです。 –

+0

私が知る限り、ファイルシステム上のファイルでなければなりません。そのパスに存在するビューテンプレート(ファイル)がありますか?また、FWIW、私はテンプレート(ビューのみ)なしで動作するようになる。 – dps

+0

テンプレートなしでこれを行うには、Mime :: Type.register "application/xls"、:xls'を使用しなければならないかもしれません(上記のRailscastに従って)。 – dps

関連する問題