我一直在使用wicked_pdf在Rails中生成一些PDF,并且它在我的开发环境中工作正常,但是当我尝试在我的生产环境中生成一个错误时,我得到500错误(但我的日志中没有特定错误).我注意到的第一件事是wkhtmltopdf二进制文件位于我的生产盒上的不同位置,所以我将以下内容添加到我的wicked_pdf.rb初始化程序中:
if Rails.env == "production"
    WickedPdf.config = {
        :exe_path => '/usr/bin/wkhtmltopdf'
    }
end
这是我在控制器中调用它的方式:
  def certificate
    @inspection = Inspection.find(params[:id])
    @council = Council.find(@inspection.councilid)  
    respond_to do |format|
        format.pdf do
            render :pdf => @inspection.slug,
                   :show_as_html => params[:debug].present?,
                   :margin => {:top            => 0,
                               :bottom         => 0,
                               :left           => 0,
                               :right          => 0}
        end
    end
  end
这是我的观点的内容:
# certificate.pdf.erb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style type="text/css">
        body {
            margin: 0;
            padding: 0; …