From 2847aae695a0aca96553752b0966d53b23d43bf8 Mon Sep 17 00:00:00 2001 From: martinsabo Date: Tue, 14 Feb 2017 17:02:50 +0100 Subject: [PATCH 1/2] Assets helper Sprockets 4 compatibility fix. Pathname attr reader was removed/deprecated. Only filename is available in Sprockets 4.x. --- lib/wicked_pdf/wicked_pdf_helper/assets.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wicked_pdf/wicked_pdf_helper/assets.rb b/lib/wicked_pdf/wicked_pdf_helper/assets.rb index c7e4db8c..de05a8c1 100644 --- a/lib/wicked_pdf/wicked_pdf_helper/assets.rb +++ b/lib/wicked_pdf/wicked_pdf_helper/assets.rb @@ -68,7 +68,7 @@ def asset_pathname(source) end else asset = find_asset(source) - asset ? asset.pathname : File.join(Rails.public_path, source) + asset ? asset.filename : File.join(Rails.public_path, source) end end From 42abd311b8f714e8faed360ebab9acac64a9a8b3 Mon Sep 17 00:00:00 2001 From: martinsabo Date: Tue, 14 Feb 2017 17:15:09 +0100 Subject: [PATCH 2/2] Sprockets 4 compatibility fix with fallback. Use pathname for cases where filename is not available. --- lib/wicked_pdf/wicked_pdf_helper/assets.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/wicked_pdf/wicked_pdf_helper/assets.rb b/lib/wicked_pdf/wicked_pdf_helper/assets.rb index de05a8c1..3d551798 100644 --- a/lib/wicked_pdf/wicked_pdf_helper/assets.rb +++ b/lib/wicked_pdf/wicked_pdf_helper/assets.rb @@ -68,7 +68,12 @@ def asset_pathname(source) end else asset = find_asset(source) - asset ? asset.filename : File.join(Rails.public_path, source) + if asset + # older versions need pathname, Sprockets 4 supports only filename + asset.respond_to?(:filename) ? asset.filename : asset.pathname + else + File.join(Rails.public_path, source) + end end end