Gem wicked pdf - CSS 不适用于 rails 5

Gem wicked pdf - CSS doesn't work with rails 5

我刚刚将我的应用程序升级到 rails 5,gem wicked pdf 不再显示 css。我什么都没改变,所以 rails 5 可能有一些规格。 如果有人弄清楚这个问题,请随时提供帮助:)

这是我的代码:

object_controller

def download
    @object = object.find(params[:object])
    respond_to do |format|
      format.html
      format.pdf do
        render pdf:          "ptf_#{@object.id}",
               layout:       'layouts/pdf_layout',
               template:     'objects/download.html.erb',
               title:        "download object",
               show_as_html: false,
               header: { content: render_to_string(template: 'objects/header_pdf.pdf.erb'), spacing: 7  },
               footer: { content: render_to_string(template: 'objects/footer_pdf.pdf.erb'), spacing: 10 },
               margin: { top: 55, bottom: 35 }
      end
    end

pdf_layout.html.erb

<% content_for :title do %><%= @title %><% end %>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<%= wicked_pdf_stylesheet_link_tag 'pdf' %>
<br>
<%= yield %>

我尝试了两个助手 wicked_pdf_stylesheet_link_tagstylesheet_link_tag wicked_pdf_asset_base64

header_pdf.html.erb

<div class="center">
      <%= image_tag wicked_pdf_asset_base64("logo.png"), class: 'header' %>
      <div class="first-class"><%= @object.title %></div>

    </div>

这是我的代码的一些摘录,只是为了向您展示我如何组织我的文件生成。我还有一个文件pdf.scss

我希望你已经找到了解决方案,但对于其他人来说,我遇到了这个问题并通过将布局的扩展名从 .html.erb 更改为 .pdf.erb 解决了它。我的布局现在称为 report.pdf.erb