Ruby on rails 3 虾桌法赢得';行不通
我一直在创建pdf文档与虾罚款。我用的是虾0.8.4。我在应用程序目录的pdf文件夹中创建了一个类,如下所示Ruby on rails 3 虾桌法赢得';行不通,ruby-on-rails-3,prawn,Ruby On Rails 3,Prawn,我一直在创建pdf文档与虾罚款。我用的是虾0.8.4。我在应用程序目录的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.s
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
我得到了错误
未定义的方法“table”
可能有什么问题?升级到Prawn版本0.12.0
,它应该可以工作。你能提供更多的上下文(更多的代码,你在哪里使用它等),因为我无法重现该错误。希望提供更多的上下文看起来你的代码是基于,谁的代码似乎有效。也许这是一个版本问题。。。?您能否尝试将对虾升级到1.0.0.rc2
,或至少升级到0.12.0
,看看这是否有帮助?是的,只需要升级到0.12.0
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