Content
Plugin development: adding wicked_pdf as a plugin dependency fails
Added by Lene Preuss almost 10 years ago
Hi,
I am currently developing an OpenProject plugin which uses the wicked_pdf gem to render PDF.
I have added these lines to my plugin’s gemspec:
s.add_dependency "wicked_pdf" s.add_dependency "wkhtmltopdf-binary"
(the latter is a dependency of wicked_pdf). The gems are installed by bundle install, as can be seen here:
$ bundle install | grep -e 'w.*pdf' Using wicked_pdf 0.11.0 Using wkhtmltopdf-binary 0.9.9.3
But upon starting rails I get the following error:
/home/lene/workspace/plugins/openproject-yellowhat-reports/config/initializers/wicked_pdf.rb:2:in `<top (required)>': uninitialized constant WickedPdf (NameError) from /home/lene/.rvm/gems/ruby-2.1.2@bookmarx/gems/railties-3.2.19/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>' [rest of backtrace available if there is interest]
The line in question (wicked_pdf.rb:2) is simply
WickedPdf.config = {
Confusingly, everything works as intended if I add wicked_pdf and wkhtmltopdf-binary to OpenProject’s Gemfile. The output of bundle install is the same, but rails starts, WickedPdf is defined and rendering PDFs works. Of course, adding dependencies to OpenProject’s Gemfile instead of from the plugin’s gemspec is not a sustainable option.
What am I doing wrong/how can this be fixed?
Thanks, Lene