我一直在用虾很好地创建 pdf 文档。我正在使用虾 0.8.4。我在 app 目录的 pdf 文件夹中创建了一个类,如下所示。
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
这是我在控制器中显示操作的代码
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
我得到错误undefined method 'table'
什么可能是错的?