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

Support for rails 6 #869

Merged
merged 2 commits into from
Dec 22, 2019
Merged

Conversation

Vasfed
Copy link
Contributor

@Vasfed Vasfed commented Nov 26, 2019

In rails 6 wicked_pdf initializer causes

DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper.

Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.
...

because of early access to ActionController::Base and can be fixed by lazy loading.

This PR fixes it by using ActiveSupport.on_load (supported since rails 3)

Also made tests pass on ruby 2.6 and fresh gem versions (had to lock sprockets to 3 because of changed newline handling)

@Vasfed Vasfed force-pushed the feature/lazy_initializer branch 2 times, most recently from 46d2fdb to cc3774f Compare November 26, 2019 19:22
@Vasfed Vasfed force-pushed the feature/lazy_initializer branch from cc3774f to cd1c92f Compare November 26, 2019 19:31
@Vasfed
Copy link
Contributor Author

Vasfed commented Nov 26, 2019

Fixed CI tests (only rails-edge (6.1 alpha) left because of sprockets' 4 newline, but that's separate story)

@kreintjes
Copy link

@Vasfed works for me, thanks!

@unixmonkey
Copy link
Collaborator

@Vasfed Awesome. Thanks for this, and also for tracking down the sprockets newline issue that has been plaguing the test suite.

@jdongelmans
Copy link

jdongelmans commented Jan 16, 2020

Is there a release planned for this? I'm getting annoyed by the Deprecation Warnings 😉
Thanks!

@jdongelmans
Copy link

@unixmonkey I've created a PR myself for a new version: #881

@unixmonkey
Copy link
Collaborator

This is now part of the gem in version 2.0. Thanks so much for the help on this! 🙇

ActionController::Base.send :prepend, PdfHelper
else
ActionController::Base.send :include, PdfHelper
ActiveSupport.on_load(:action_controller) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this new approach break the compatibility of wicked_pdf and remotipart? I do observe a bug if wicked_pdf 2.0.x is used with remotipart. In Ruby 2.6, the bug is announced as a FrozenError. We get more information under Ruby <2.5 to see that there is indeed a loop of rendering.

Copy link

@darrenterhune darrenterhune Mar 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm this does break our app. I forked this repo and simply rolled back to a simpler version of railtie.rb just to debug this and we are working again darrenterhune@ccc8615 that said, wicked_pdf still worked locally, it was just barfing on CircleCI with this #891

entantoencuanto added a commit to decidim/decidim that referenced this pull request Mar 8, 2021
There is a Rails 6 deprecation warning very common in some gems:
rails/rails#36546. In wicked_pdf this
issue is solved in the most recent versions
mileszs/wicked_pdf#869
entantoencuanto added a commit to decidim/decidim that referenced this pull request Mar 8, 2021
There is a Rails 6 deprecation warning very common in some gems:
rails/rails#36546. In wicked_pdf this
issue is solved in the most recent versions
mileszs/wicked_pdf#869
entantoencuanto added a commit to decidim/decidim that referenced this pull request Mar 8, 2021
There is a Rails 6 deprecation warning very common in some gems:
rails/rails#36546. In wicked_pdf this
issue is solved in the most recent versions
mileszs/wicked_pdf#869
entantoencuanto added a commit to decidim/decidim that referenced this pull request Mar 8, 2021
There is a Rails 6 deprecation warning very common in some gems:
rails/rails#36546. In wicked_pdf this
issue is solved in the most recent versions
mileszs/wicked_pdf#869
entantoencuanto added a commit to decidim/decidim that referenced this pull request Mar 9, 2021
There is a Rails 6 deprecation warning very common in some gems:
rails/rails#36546. In wicked_pdf this
issue is solved in the most recent versions
mileszs/wicked_pdf#869
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.

6 participants