wicked_pdf挂在rails应用程序上 - rails 4.2.5 - ruby​​ 2.3.0

时间:2016-06-13 19:37:48

标签: ruby-on-rails ruby-on-rails-4 wicked-pdf

我试图实现WickedPDF从html页面生成PDF。当我将URL .pdf扩展名添加到页面似乎处理的URL时,但PDF不会在dev或prod环境中呈现。

我在生产中尝试了这个(Heroku),返回的信息是:

at=error code=H12 desc="Request timeout"

的Gemfile

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'

application.rb中

config.middleware.use WickedPdf::Middleware

controller.rb

def show
    respond_to do |format|
      format.html
      format.pdf do
        render :pdf => "invoice", :layout => 'show.html.erb'
      end
    end
  end

终端响应

Started GET "/invoices/1.pdf" for ::1 at 2016-06-13 20:28:19 +0100
Processing by InvoicesController#show as HTML
  Parameters: {"id"=>"1"}
  Invoice Load (0.2ms)  SELECT  "invoices".* FROM "invoices" WHERE "invoices"."id" = ? LIMIT 1  [["id", 1]]
  Rendered invoices/show.html.erb within layouts/application (39.8ms)
Completed 200 OK in 109ms (Views: 107.6ms | ActiveRecord: 0.2ms)
"***************[\"/Users/justdanlee/.rvm/gems/ruby-2.3.0/bin/wkhtmltopdf\", \"-q\", \"file:////var/folders/zq/6w81cths1jscg4dfnn56jsfm0000gn/T/wicked_pdf20160613-1291-34i0va.html\", \"/var/folders/zq/6w81cths1jscg4dfnn56jsfm0000gn/T/wicked_pdf_generated_file20160613-1291-17z0i3b.pdf\"]***************"

这是一个已知问题吗?

0 个答案:

没有答案