Rails + Prawn: undefined method `table' for #<Prawn::Document:0x007fda2d594a98>:
Asked Answered
H

2

19

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?

Hustler answered 27/6, 2014 at 15:21 Comment(1)
it's prawn/table, not prawn/tablesComanche
E
35

You should add these lines into your Gemfile.

gem 'prawn', '~> 1.2.1'
gem 'prawn-table', '~> 0.1.0'
Exclude answered 21/8, 2014 at 16:20 Comment(2)
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:ClassJaw
you can do 'prawn-table', '~> 0.2.0' now.Shadchan
H
14

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

Hustler answered 27/6, 2014 at 16:5 Comment(1)
thank you ! any ideas where this pdf.prawn file is located?Poindexter

© 2022 - 2024 — McMap. All rights reserved.