rake db:migrate - 未初始化的常量WickedPdf

时间:2013-04-20 15:03:12

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

运行rake db:migrate时,我收到错误:uninitialized constant WickedPdf

我已按照本页https://github.com/mileszs/wicked_pdf/issues/53中列出的说明安装了WickedPdf。

我可以从命令行运行wkhtmltopdf二进制文件,我的wicked_pdf.rb看起来像这样:

WickedPdf.config = {
  :exe_path => '/usr/local/bin/wkhtmltopdf'
}

这是我的宝石列表供参考:

$ bundle exec gem list

*** LOCAL GEMS ***

actionmailer (2.3.14)
actionpack (2.3.14)
activerecord (2.3.14)
activeresource (2.3.14)
activesupport (2.3.14)
brightbox (2.3.9)
bundler (1.3.5)
capistrano (2.14.2)
highline (1.6.16)
hoe (3.5.2)
hpricot (0.8.2)
htmldoc (0.2.3)
json (1.7.7)
macaddr (1.6.1)
mysql (2.9.1)
net-scp (1.1.0)
net-sftp (2.1.1)
net-ssh (2.6.7)
net-ssh-gateway (1.2.0)
paginator (1.1.1)
rack (1.1.6)
rails (2.3.14)
rake (10.0.4)
rdoc (4.0.1)
RedCloth (4.2.9)
rmagick (2.13.1)
systemu (2.5.2)
uuid (2.0.2)
will_paginate (2.3.16)
wkhtmltopdf-binary (0.9.9.1)

由于

1 个答案:

答案 0 :(得分:2)

如果您在运行rake db:migrate时遇到问题,可以尝试使用defined?包装初始化程序:

if defined?(WickedPdf)
  WickedPdf.config = {
    :exe_path => '/usr/local/bin/wkhtmltopdf'
  }
end