NoMethodError:未定义的方法`chomp'为零:NilClass

时间:2014-10-02 02:17:32

标签: ruby-on-rails ruby-on-rails-3 pdfkit

日志

/gems/pdfkit-0.6.2/lib/pdfkit/configuration.rb:22 in "wkhtmltopdf"  
/gems/pdfkit-0.6.2/lib/pdfkit/pdfkit.rb:32 in "initialize"
/gems/pdfkit-0.6.2/lib/pdfkit/middleware.rb:22 in "new"
/gems/pdfkit-0.6.2/lib/pdfkit/middleware.rb:22 in "call"
/gems/warden-1.2.3/lib/warden/manager.rb:35 in "block in call"
/gems/warden-1.2.3/lib/warden/manager.rb:34 in "catch"
/gems/warden-1.2.3/lib/warden/manager.rb:34 in "call"
/gems/actionpack-3.2.17/lib/action_dispatch/middleware/best_standards_support.rb:17 in "call"
/gems/rack-1.4.5/lib/rack/etag.rb:23 in "call"
/gems/rack-1.4.5/lib/rack/conditionalget.rb:25 in "call"
/gems/actionpack-3.2.17/lib/action_dispatch/middleware/head.rb:14 in "call"
/gems/actionpack-3.2.17/lib/action_dispatch/middleware/params_parser.rb:21 in "call"
/gems/actionpack-3.2.17/lib/action_dispatch/middleware/flash.rb:242 in "call"
/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210 in "context"
/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205 in "call"

我在Exception(Airbrake)中收到此错误。无法知道此错误的来源,因此无法修复。

可能是这个错误来自pdfkit但是当我在我的本地测试时,它工作正常,并且在服务器上工作正常,但每天我收到此错误。

1 个答案:

答案 0 :(得分:2)

关于Ruby的精彩之处在于它是在源代码中分发的。追踪line 22 of configuration.rb非常容易:

@wkhtmltopdf ||= (defined?(Bundler::GemfileError) && File.exists?('Gemfile') ? `bundle exec which wkhtmltopdf` : `which wkhtmltopdf`).chomp

因此,which wkhtmltopdf会返回nil。你需要确保它没有。考虑安装wkhtmltopdf,不管是什么。 gem中的说明明确说明这是必需的安装步骤:https://github.com/pdfkit/pdfkit