No such file or directory @ rb_sysopen - public/receipts/416981.pdf

感情迁移 提交于 2019-12-18 04:41:13

问题


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.


回答1:


After putting a complete path, resolved my problem.

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



来源:https://stackoverflow.com/questions/28403667/no-such-file-or-directory-rb-sysopen-public-receipts-416981-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!