2

I'm trying to get PDF table to work ( following railscast example ) but i get the error undefined methodtable' for #

This is the pdf class lib (followed railscast way of doing) :

class FeedbackPdf < Prawn::Document
  def initialize
    super
      text_label
      pdf_feedbacks
  end

  def text_label
    text "Customers Feedback:"
  end

  def pdf_feedbacks
    table[[1,2],[3,4]]
  end
end

Can anyone help me please ?

BC2
  • 1,129
  • 1
  • 11
  • 22
  • not sure but in this [doc](http://prawnpdf.org/manual.pdf) I see example `table(data, :header => true)` It means that table is method which accepts some params. According to your code you try to call `table[]` or smth like this (I mean Ruby interprets your code in this way). Try to write `table([[1,2],[3,4]])` – gotva Jul 12 '14 at 07:31
  • I did try table([],[]) but i still get the same error. – BC2 Jul 12 '14 at 09:19

2 Answers2

3

According to this changelog, table is now disabled by default in prawn and will be moved in its own gem.

Until then, you can require it at the top of your file:

require "prawn/table"
siekfried
  • 2,964
  • 1
  • 21
  • 36
  • Yes thank you. I solved it by require 'prawn/table' too. Thanks alot. By the way do you know how i can make show different colors for the pie chart in PDF ? I'm currently using prawn-shape to draw the pie charts. But can't color it. – BC2 Jul 14 '14 at 13:16
  • I never used charts in my prawn documents sorry, but I would recommend the same doc as @gotva, it helped me solve almost all my issues. – siekfried Jul 14 '14 at 13:19
  • I am using Ruby 2.1.2, Rails 4.1.1. I have same problem as mentioned above, but when i add "require 'prawn/table'" at top of my file it says "cannot load such file -- prawn/table". Any ideas on this? – polarcare Mar 05 '15 at 12:46
  • hi - any idea in which file and where (location wise) should the entry: 'require "prawn/table"' be added? – BenKoshy Oct 26 '15 at 12:46
0

As of Prawn 1.2.0, Prawn::Table has been extracted into its own semi-officially supported gem.

Please see https://github.com/prawnpdf/prawn-table for more details.

Gemfile:

gem 'prawn-table'

Run:

bundle install

That should fix it. No need to

require "prawn/table"

any more.