Open sepastian opened 8 years ago
I had the same issue. Was able to resolve by changing the first few lines of _header.pdf.prawn to:
rel_path = Rails.application.assets_manifest.assets[Spree::PrintInvoice::Config[:logo_path]]
im = Rails.root.join("public","assets",rel_path)
if im && File.exist?(im)
pdf.image im, vposition: :top, height: 40, scale: Spree::PrintInvoice::Config[:logo_scale]
end
@mdavo6 This solution doesn't work in the development environment.
@aman29april Agree. Have just had some time to work on a better solution which works in production and development. What about the below as an approach? Working for me in development and production.
if Rails.env.production? &&
Rails.application.assets_manifest.assets[Spree::PrintInvoice::Config[:logo_path]].present?
manifest_dir = Rails.application.assets_manifest.dir
logo_path = Rails.application.assets_manifest.assets[Spree::PrintInvoice::Config[:logo_path]]
im = File.join(manifest_dir, logo_path)
elsif Rails.application.assets.find_asset(Spree::PrintInvoice::Config[:logo_path]) != nil
im = Rails.application.assets.find_asset(Spree::PrintInvoice::Config[:logo_path]).filename
end
if im && File.exist?(im)
pdf.image im, vposition: :top, height: 40, scale: Spree::PrintInvoice::Config[:logo_scale]
end
I have updated sprockets and now get
ActionView::Template::Error (undefined method
find_asset' for nil:NilClass)`.Rails.application.assets
isnil
unlessassets.compile
is set, which defaults tofalse
in production.See https://github.com/rails/sprockets-rails/issues/237, i.e.: