Rails 2.3.8 上的 PDFKit 中间件问题
我已经在我的 Ubuntu 8.04 服务器上安装了 PDFKit 和 wkhtmltopdf。我正在尝试在 Rails 2.3.8 应用程序中使用 PDFKit 作为中间件,并将以下几行添加到environment.rb(按照 jdpace pdfkit 页面上的指示):
require 'pdfkit' config.middleware.use PDFKit::Middleware
我的 Mongrel 似乎已启动,但一旦我请求页面,Mongrel 日志中就会出现以下错误:
** 将 PID 文件写入 tmp/pids/mongrel.9270.pid /!\ 故障安全 /!\ 2010 年 9 月 7 日星期二 16:42:20 +0000 状态:500 内部服务器错误 nil:NilClass 的未定义方法 match' /usr/lib/ruby/gems/1.8/gems/pdfkit-0.4.6/lib/pdfkit/middleware.rb:12:in
调用' /home/rails/livetest-carbon-hub/releases/20100907133547/vendor/rails/actionpack/lib/action_controller/string_coercion.rb:25:in call' /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in
调用' /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in `call'
还有其他人遇到过这个吗?
非常感谢任何帮助或建议!
I have installed PDFKit and wkhtmltopdf on my Ubuntu 8.04 server. I am trying to use PDFKit as middleware in my Rails 2.3.8 app and have added the following lines to environment.rb (as directed on the jdpace pdfkit page):
require 'pdfkit'
config.middleware.use PDFKit::Middleware
My Mongrel seems to start up but as soon as I request a page the following error appears in the Mongrel log:
** Writing PID file to tmp/pids/mongrel.9270.pid
/!\ FAILSAFE /!\ Tue Sep 07 16:42:20 +0000 2010
Status: 500 Internal Server Error
undefined method match' for nil:NilClass
call'
/usr/lib/ruby/gems/1.8/gems/pdfkit-0.4.6/lib/pdfkit/middleware.rb:12:in
/home/rails/livetest-carbon-hub/releases/20100907133547/vendor/rails/actionpack/lib/action_controller/string_coercion.rb:25:in call'
call'
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in `call'
Has anybody else come across this ?
Any help or suggestions gratefully received !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
require 'pdfkit' 需要位于
Rails::Initializer.run do |config|
之上config.middleware.use
PDFKit::Middleware
需要位于运行块内的下方。
您可能还想
添加config.gem 'pdfkit'
和
Mime::Type.register 'application/pdf', :pdf 。
在其中
require 'pdfkit' needs to be above the
Rails::Initializer.run do |config|
and
config.middleware.use PDFKit::Middleware
needs to be underneath, inside the run block.
You probably also want to add
config.gem 'pdfkit'
and
Mime::Type.register 'application/pdf', :pdf
in there as well.