1

我正在尝试设置 PDFKit,但我什至无法运行我的应用程序。我不断收到此错误:

`require': cannot load such file -- pdfkit (LoadError)

这是我的整个 application.rb 文件。

require File.expand_path('../boot', __FILE__)

require 'rails/all'
require 'pdfkit'

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
   Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
  #Bundler.require(:default, :assets, Rails.env)
end

module Form
  class Application < Rails::Application

    # Configure the default encoding used in templates for Ruby 1.9.
    config.encoding = "utf-8"

    # Configure sensitive parameters which will be filtered from the log file.
    config.filter_parameters += [:password]


    # Enable the asset pipeline
    config.assets.enabled = true

    # Version of your assets, change this if you want to expire all your assets
    config.assets.version = '1.0'
    config.middleware.use PDFKit::Middleware

  end
end

我已按照 pdfkit wiki 页面上的说明进行操作,但我遇到了这个错误。我认为它找不到 pdfkit gem,但似乎已安装。请帮忙。

4

1 回答 1

2

require 'pdfkit'从 application.rb 中删除

添加到您的Gemfile

gem "pdfkit"

然后bundle从您的 rails 根目录运行命令。

于 2012-03-07T08:08:05.760 回答