ruby-on-rails-3 - 环境与 WickedPDF 和 Heroku 冲突

标签 ruby-on-rails-3 heroku wicked-pdf

我正在使用 WickedPDF,我基本上有两个包含二进制文件的 gem:

gem "wkhtmltopdf-heroku", "1.0.0"
gem "wkhtmltopdf-binary", "0.9.5.3"

第一个应该只用于生产,第二个用于开发。如果我的 Gemfile 如下所示,则无法部署到 Heroku:

group :development do
  gem "wkhtmltopdf-binary", "0.9.5.3"
end

group :production do
  gem "wkhtmltopdf-heroku", "1.0.0"
end

如果我有它,它也不起作用:

group :production do
  gem "wkhtmltopdf-heroku", "1.0.0"
end

如果我没有组,它就可以工作。就像:

gem "wkhtmltopdf-heroku", "1.0.0"

我得到的错误是:

运行时错误:wkhtmltopdf 的位置未知

为什么会这样?为什么 Heroku 不使用生产组?

最佳答案

WickedPdf 试图找出 wkhtmltopdf 二进制文件所在的位置,但在某些系统(尤其是共享服务器)上可能会遇到困难。

您可能必须在初始化程序中手动设置它,如下所示:

bin_location = case Rails.env
  when 'production' then "/wherever/your/binary/is/bin/wkhtmltopdf"
  when 'development' then "/local/path/to/wkthmltopdf"
  else `which wkhtmltopdf`
end
WickedPdf.config = { :exe_path => bin_location }

关于ruby-on-rails-3 - 环境与 WickedPDF 和 Heroku 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11005609/

相关文章:

ruby-on-rails-3 - 轨道 3 : Choose and run a Mechanize script from inside Rails action.

ruby-on-rails - 有_许多 :through association error 'could not find the source association'

ruby-on-rails - Rails 3 中 ruby​​ script/about 的等效项是什么?

typescript - Heroku - fatal error : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

ruby-on-rails-3 - 错误线程错误: Attempt to unlock a mutex which is locked by another thread

python - 自定义 LIBFFI Heroku buildpack 的问题

heroku - Heroku 的帐户验证会收取任何费用吗?

wicket - Apache Wicket 可书签 url 向链接添加了一个附加参数,为什么?

heroku - Wicked_PDF 不渲染通过 Asset Sync 在生产中托管的 HTML 和 CSS Assets

ruby-on-rails - 在 wicked_pdf 中显示签名板 - Rails