2015-09-29 119 views
2

我已經使用了邪惡的pdf gem for html在pdf中生成pdf。它不適合我,它會拋出這樣的錯誤ActionView :: MissingTemplate at /events/calendar_month_print.pdf 缺少具有{:locale => [:en],:formats => [:pdf],:variants => []的模板事件/ calendar_month_print.html.erb::handlers => [:erb,:builder,:raw, :ruby,:rabl,:rxls,:「xls.rxls」,::jbuilder]}。搜索:,我也在我的應用程序中創建了calendar_month_print.html.erb文件。我不知道我在哪裏失蹤。rails 4 wicked pdf missing template

我的Gemfile

gem 'wicked_pdf' 
gem 'wkhtmltopdf-binary' 

我的控制器文件

respond_to do |format| 
    format.html 
    format.pdf do 
     render :pdf => "monthly_events.pdf",:template => "events/calendar_month_print.html.erb" 
    end 
    end 

我的視圖文件

<%= button_to "Print as pdf", calendar_month_print_events_path(format: "pdf"), :class => "btn btn-primary button monthly_print pull-right",:method => :get,target: '_blank' %> 

我的配置/初始化/ mime_types.rb

Mime::Type.register "application/pdf", :pdf 

我的配置/初始化/ wicked_pdf.rb

WickedPdf.config = { 
#:wkhtmltopdf => '/usr/local/bin/wkhtmltopdf', 
#:layout => "pdf.html", 
:exe_path => '/usr/local/bin/wkhtmltopdf' 
} 
+0

你有名爲'calendar_month_print.html.erb'的文件嗎? – Pavan

+0

是名爲calendar_month_print.html.erb的文件。 – Karthick

+0

它在'app/views/events'裏面嗎? – Pavan

回答

4

當你給render :pdf => "monthly_events.pdf",:template => "events/calendar_month_print.html.erb",Rails的預計,在一個名爲app/views/events文件calendar_month_print.html.erb。如果你把它放在其他地方,然後將它移動到app/views/events

相關問題