Skip to content

Commit

Permalink
Allow/Fix precompiled assets with Propshaft pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
serggl committed Jun 11, 2024
1 parent 26bc414 commit ad8686a
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions lib/wicked_pdf/wicked_pdf_helper/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,9 @@ def initialize(url, response)
end
end

class PropshaftAsset < SimpleDelegator
def content_type
super.to_s
end

class PropshaftAsset < LocalAsset
def to_s
content
end

def filename
path.to_s
Rails.application.assets.resolver.read(path)
end
end

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ad8686a

Please sign in to comment.