使用 PDFKit 时出现未初始化的常量错误
在我的 Rails 应用程序中,我尝试从 html 生成 pdf 并尝试使用 pdfkit 和 wkhtmltopdf。我试图从最简单的代码开始,例如:
kit = PDFKit.new("<p>This is some text.</p>")
pdf = kit.to_file "/home/user/test.pdf"
但我最终遇到以下错误:
uninitialized constant TestController::PDFKit
TestController 是我的控制器名称。仅供参考,我使用的是 Fedora12 和 Rails 2.2。
需要一些帮助。有人在吗?
In my rails app, I am trying to generate pdf from html and trying to use pdfkit and wkhtmltopdf. I am trying to start by simplest code like:
kit = PDFKit.new("<p>This is some text.</p>")
pdf = kit.to_file "/home/user/test.pdf"
But I am ending up with the following error:
uninitialized constant TestController::PDFKit
TestController is my controller name. FYI, I am using Fedora12 and rails 2.2.
Need some help. Anybody there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您为您的应用程序添加 pdf mime 类型:
打开 config/initializer/mime_types.rb ,添加以下代码:
希望对您有帮助。
You add pdf mime type for your app:
open config/initializer/mime_types.rb , add this code :
Hope it helps you.