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?
Upgrade to Prawn version 0.12.0 and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With