我試圖用一個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