wicked pdf 在生产中找不到我的资产

wicked pdf doesnt find my assets in production

我的 CSS of wicked pdf 有问题 一切都在本地工作,但在生产

中找不到pdf.css
ActionView::Template::Error (The asset "components/pdf.css" is not present in the asset pipeline.):
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<%= wicked_pdf_stylesheet_link_tag 'components/pdf.css' %>
 </head>
<body>
<%= yield %>

我的pdf.html.erb

<!doctype html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
    <%= wicked_pdf_stylesheet_link_tag 'components/pdf' %>
  </head>
  <body>
      <%= yield %>
  </body>
</html>

我的components/pdf.css

.document-pdf {
  background-image: asset-data-url("fond.png");
  background-size: 23cm 13cm;
  background-color: white;
  background-repeat: no-repeat;
  background-position: 50% 70%;
  font-family: "Helvetica Neue", Helvetica;
}

您是否已将 pdf.css 添加到 initializers/assets.rb 中的预编译资产?

Rails.application.config.assets.precompile += ['pdf.css']

每个问题都可能因不同的原因而发生。所以我想分享我的,如果有人可能有同样的情况。

  • Ruby 在某个时候更新了(此错误发生在更新后)。 我们在 heroku 控制台上得到 'pdf.css not find error'。

我们 运行 gem update sass-rails gem update wicked_pdfgem update wkhtmltopdf-binary 在 heroku 控制台上。

最佳