Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include WickedPdfHelper::Assets in the right instance of ActionView::Base #938

Closed
wants to merge 1 commit into from

Conversation

yoones
Copy link
Contributor

@yoones yoones commented Aug 26, 2020

Context:

A Rails application with config.action_controller.asset_host defined (CDN such as cloudfront)

Problem:

In a view rendered by a controller, asset_path returns a full url but through wicked_pdf, asset_path returns only a path (without the host), thus breaking assets provided through a CDN.

We can work around this issue by giving an absolute url to wicked_pdf_image_tag but it's not ideal.

# This won't work with a CDN
wicked_pdf_image_tag 'file.png'

# This works with a CDN
wicked_pdf_image_tag ActionController::Base.helpers.asset_path('file.png')

Solution:

I suggest to fix lib/wicked_pdf/railtie.rb to make asset_path (which is used in lib/wicked_pdf/wicked_pdf_helper/assets.rb) aware of config.action_controller.asset_host for it to work as expected.

The fix consist of including WickedPdfHelper::Assets in the right instance of ActionView::Base once it's loaded.

@yoones yoones force-pushed the bugfix_railties_on_load branch 2 times, most recently from b8437e0 to f82c505 Compare August 26, 2020 14:40
…ce of ActionView::Base so that asset_path become aware of asset_host configuration.
@yoones yoones force-pushed the bugfix_railties_on_load branch from f82c505 to efa8e25 Compare August 26, 2020 14:54
@yoones yoones closed this Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant