rails 4 wicked pdf 缺少模板

rails 4 wicked pdf missing template

我使用了 wicked pdf gem for html to pdf generate in rails 4.It 对我不起作用并且它抛出这样的错误 ActionView::MissingTemplate 在 /events/calendar_month_print.pdf 缺少模板 events/calendar_month_print.html.erb 与 {:locale=>[:en], :formats=>[:pdf], :variants=>[], :handlers=>[:erb, :builder , :raw, :ruby, :rabl, :rxls, :"xls.rxls", :jbuilder]}。在以下位置搜索:,我还在我的 app.I 中创建了 calendar_month_print。html.erb 文件不知道我在哪里丢失了。

我的gem文件

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'  %>

我的config/initializers/mime_types.rb

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

我的config/initializers/wicked_pdf.rb

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

当您提供 render :pdf => "monthly_events.pdf",:template => "events/calendar_month_print.html.erb" 时,Rails 需要 app/views/events 中名为 calendar_month_print.html.erb 的文件。如果你把它放在其他地方,然后把它移到 app/views/events