Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
829 views
in Technique[技术] by (71.8m points)

ruby on rails 4.2 - No such file or directory @ rb_sysopen - public/receipts/416981.pdf

Below on line no. 2, I am getting this error:

Errno::ENOENT in OrdersController#print

def generate_receipt(filename = nil, current_user = nil)
    filename ||= "public/receipts/#{id}.pdf"
    Prawn::Document.generate(filename, :page_layout => :portrait, :page_size => 'LETTER', :skip_page_creation => false, :top_margin => 50, :left_margin => 50)do |pdf|

      pdf_receipt_data(pdf, false, 'store_front', current_user)

      pdf.number_pages "<page> of <total>", :at => [0, 0]

    end
end

On my localhost this code is working but on testing env I am getting this error. I am using rails 4.2.
Please help me out.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

After putting a complete path, resolved my problem.

filename ||= "#{Rails.root}/public/receipts/#{id}.pdf"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...