18

I'm using Rails 4 + prawn_rails + the latest version of prawn (v 1.1.0) and I noticed in the changelog here: https://github.com/prawnpdf/prawn/wiki/CHANGELOG that tables are now separated.

I followed the instructions to require "prawn/tables". I did this by adding a file in my lib directory:

lib/prawn.rb

require "prawn/tables"

I restarted my rails server and I still get the error:

NoMethodError - undefined method `table' for #<Prawn::Document:0x007fda2d594a98>:

How do I fix this?

bigpotato
  • 26,262
  • 56
  • 178
  • 334

2 Answers2

35

You should add these lines into your Gemfile.

gem 'prawn', '~> 1.2.1'
gem 'prawn-table', '~> 0.1.0'
Paulo Tarud
  • 588
  • 5
  • 5
  • If you're using `Bundler.require` (such as in a Rails app), the gems need to be listed in **this exact order**. Otherwise you may get this error on startup: `undefined method 'extensions' for Prawn::Document:Class` – Isaac Betesh Aug 28 '14 at 19:07
  • 2
    you can do 'prawn-table', '~> 0.2.0' now. – szabcsee Oct 01 '14 at 11:32
13

The line in the documentation is WRONG. add require 'prawn/table' to your .pdf.prawn file on the top and it will work.

bigpotato
  • 26,262
  • 56
  • 178
  • 334