Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prawn table method won't work

I have been creating pdf documents fine with prawn. I am using prawn 0.8.4. I have created a class in pdf folder in the app directory like so.

class SchoolPdf < Prawn::Document
  def initialize(school)
    super(top_margin: 70)
    @school = school
    school_name
    line_items

  end

  def school_name
    text "School: #{@school.school_name}", size: 30, style: :bold
  end

   def line_items
    move_down 20
    table [[1,2],[3,4]]
   end
end

This is code from my show action in the controller

def show
  @school = School.find(params[:id])
  respond_to do |format|
  format.html
  format.pdf  do
    pdf = SchoolPdf.new(@school)

    send_data pdf.render,filename: "#{@school.school_name}_report.pdf",
                         type: "application/pdf",
                         disposition: "inline"
  end

I get the error undefined method 'table' what could be wrong?

like image 504
Wasswa Samuel Avatar asked Jan 30 '26 05:01

Wasswa Samuel


1 Answers

Upgrade to Prawn version 0.12.0 and it should work.

like image 132
Paul Fioravanti Avatar answered Jan 31 '26 17:01

Paul Fioravanti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!