css - wicked pdf 在生产中找不到我的 Assets

标签 css ruby-on-rails ruby wicked-pdf

我的 wicked pdf CSS 有问题 一切都在本地工作,但在生产中找不到 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>

我的组件/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 中的预编译 Assets ?

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

关于css - wicked pdf 在生产中找不到我的 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47675591/

相关文章:

html - 标题图片位置固定

css - 溢出-y : scroll; is NOT working on table

ruby-on-rails - 如何使用带有 rails 的祖先 gem 来急切加载根?

ruby-on-rails - 基于 Rails 中的用户输入安全地动态调用方法

javascript - 尝试在rails中添加button_tag会导致意外的tIDENTIFIER语法错误

javascript - div之间的等边距

javascript - 启用拖放 VML 形状

ruby-on-rails - Heroku 上的 Thin vs Unicorn

ruby-on-rails - 具有多个连接的 ActiveRecord 查询无法识别关系

ruby-on-rails - 在 Rails 环境之外测试(使用 RSpec) Controller