我试图用一个prawn
类中rails 3.2
帮手,但轨道抛出:Rails/Prawn:我如何在Prawn类中使用rails helper?
undefined method `number_with_precision' for #<QuotePdf:0x83d4188>
虾类
class QuotePdf < Prawn::Document
def initialize(quote)
super()
text "sum: #{number_with_precision(quote.sum)}"
end
end
控制器
def show
@quote = current_user.company.quotes.where(:id => params[:id]).first
head :unauthorized and return unless @quote
respond_with @quote, :layout => !params[:_pjax] do |format|
format.pdf do
send_data QuotePdf.new(@quote).render, filename: "Devis-#{@quote.date_emission.strftime("%d/%m/%Y")}.pdf",
type: "application/pdf"
end
end
end
感谢您的帮助。
Rails中3.2.11行之有效我。 Siekfried's没有。谢谢! – 2013-05-07 04:10:29
包括必须在最新的rails版本之外的类(定义类之前)! – mArtinko5MB 2013-12-03 10:00:47