{"id":1531,"date":"2022-08-30T15:17:18","date_gmt":"2022-08-30T15:17:18","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/pdfkit-middleware-problem-on-rails-2-3-8-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:17:18","modified_gmt":"2022-08-30T15:17:18","slug":"pdfkit-middleware-problem-on-rails-2-3-8-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/pdfkit-middleware-problem-on-rails-2-3-8-collection-of-common-programming-errors\/","title":{"rendered":"PDFKit middleware problem on Rails 2.3.8-Collection of common programming errors"},"content":{"rendered":"<p>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):<\/p>\n<p>require &#8216;pdfkit&#8217; config.middleware.use PDFKit::Middleware<\/p>\n<p>My Mongrel seems to start up but as soon as I request a page the following error appears in the Mongrel log:<\/p>\n<p>** 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 <code>match' for nil:NilClass \/usr\/lib\/ruby\/gems\/1.8\/gems\/pdfkit-0.4.6\/lib\/pdfkit\/middleware.rb:12:in<\/code>call&#8217; \/home\/rails\/livetest-carbon-hub\/releases\/20100907133547\/vendor\/rails\/actionpack\/lib\/action_controller\/string_coercion.rb:25:in <code>call' \/usr\/lib\/ruby\/gems\/1.8\/gems\/rack-1.1.0\/lib\/rack\/head.rb:9:in<\/code>call&#8217; \/usr\/lib\/ruby\/gems\/1.8\/gems\/rack-1.1.0\/lib\/rack\/methodoverride.rb:24:in `call&#8217;<\/p>\n<p>Has anybody else come across this ?<\/p>\n<p>Any help or suggestions gratefully received !<\/p>\n<ol>\n<li>\n<p>require &#8216;pdfkit&#8217; needs to be above the<\/p>\n<p>Rails::Initializer.run do |config|<\/p>\n<p>and<\/p>\n<p>config.middleware.use PDFKit::Middleware<\/p>\n<p>needs to be underneath, inside the run block.<\/p>\n<p>You probably also want to add<\/p>\n<p>config.gem &#8216;pdfkit&#8217;<\/p>\n<p>and<\/p>\n<p>Mime::Type.register &#8216;application\/pdf&#8217;, :pdf<\/p>\n<p>in there as well.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-27 05:07:13. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>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 &#8216;pdfkit&#8217; config.middleware.use PDFKit::Middleware My Mongrel seems to start up but as soon as I request [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1531","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1531"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1531\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}