【发布时间】:2013-12-29 19:04:42
【问题描述】:
我有一个 Rails 应用程序,我在其中使用 wicked_pdf 生成 PDF。这一切都很好并且可以在本地工作,但是当推送到 heroku 时,PDF 会呈现,但没有应用样式表。
特别是对于 PDF 渲染,我有一个 CSS 文件:app/assets/stylesheets/pdf.css.scss。在form.pdf.haml 中,我像这样加载样式表:
!!!
%html{lang: "en", "xml:lang" => "en", xmlns: "http://www.w3.org/1999/xhtml"}
%head
%meta{content: "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
= wicked_pdf_stylesheet_link_tag "pdf"
如前所述,它在本地运行良好,但是当推送到 heroku 时,我收到此错误:
ActionView::Template::Error (No such file or directory - /app/public/pdf.css)
我必须做些什么才能在 heroku 上进行这项工作?
编辑:我找到了这个 Gihub repo https://github.com/jordan-brough/heroku-pdf,这是一个在 heroku 上使用 wicked_pdf 的示例应用程序。在请求 PDF 时,通过调整 environment.rb 以提供来自 public 文件夹的 css 文件确实很有帮助。
【问题讨论】:
标签: css ruby-on-rails pdf heroku wicked-pdf