diff --git a/lib/wicked_pdf/wicked_pdf_helper/assets.rb b/lib/wicked_pdf/wicked_pdf_helper/assets.rb index 77163265..d596dcb9 100644 --- a/lib/wicked_pdf/wicked_pdf_helper/assets.rb +++ b/lib/wicked_pdf/wicked_pdf_helper/assets.rb @@ -28,20 +28,6 @@ def initialize(url, response) end end - class PropshaftAsset < SimpleDelegator - def content_type - super.to_s - end - - def to_s - content - end - - def filename - path.to_s - end - end - class SprocketsEnvironment def self.instance @instance ||= Sprockets::Railtie.build_environment(Rails.application) @@ -72,6 +58,12 @@ def filename end end + class PropshaftAsset < LocalAsset + def to_s + Rails.application.assets.resolver.read(path) + end + end + def wicked_pdf_asset_base64(path) asset = find_asset(path) raise MissingLocalAsset, path if asset.nil? @@ -200,7 +192,7 @@ def find_asset(path) if Rails.application.assets.respond_to?(:find_asset) Rails.application.assets.find_asset(path, :base_path => Rails.application.root.to_s) elsif defined?(Propshaft::Assembly) && Rails.application.assets.is_a?(Propshaft::Assembly) - PropshaftAsset.new(Rails.application.assets.load_path.find(path)) + PropshaftAsset.new(path) elsif Rails.application.respond_to?(:assets_manifest) asset_path = File.join(Rails.application.assets_manifest.dir, Rails.application.assets_manifest.assets[path]) LocalAsset.new(asset_path) if File.file?(asset_path)