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

Transition to Zeitwerk for Autoloading #1432

Closed
4 tasks done
murny opened this issue Jan 24, 2020 · 2 comments
Closed
4 tasks done

Transition to Zeitwerk for Autoloading #1432

murny opened this issue Jan 24, 2020 · 2 comments

Comments

@murny
Copy link
Contributor

murny commented Jan 24, 2020

Update to Zeitwerk: https://github.com/fxn/zeitwerk

  • Hopefully minor to no work required
  • Cleanup any compatibility issues
  • Remove old dependency code (if we have require_dependencies or using eager_load_paths, etc)
  • Port over code and refactor our dependency of canonical-rails as this gem does not work with Zeitwerk. See comment (Transition to Zeitwerk for Autoloading #1432 (comment) for more info
@murny murny added the rails6 label Jan 24, 2020
@mbarnett mbarnett mentioned this issue Jan 24, 2020
4 tasks
@weiweishi weiweishi added the 5 label Jan 24, 2020
@murny
Copy link
Contributor Author

murny commented Jan 31, 2020

Will probably need to port over the code we need for our canonical urls as currently this canonical-rails gem will does not seem to work with zeitwerk and no fix on the horizon: jumph4x/canonical-rails#54 (so it's been 7-8 months now since that issue has been created, probably safe to say nothing going to happen anytime soon 🤔)

DEPRECATION WARNING: Initialization autoloaded the constant CanonicalRails::TagHelper.

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

Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload CanonicalRails::TagHelper, for example,
the expected changes won't be reflected in that stale Module object.

`config.autoloader` is set to `classic`. This autoloaded constant would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.

Please, check the "Autoloading and Reloading Constants" guide for solutions.
 (called from <top (required)> at /Users/murny/Code/jupiter/config/environment.rb:5)

For us think we should just replaced this gem on our side as we use 2 cents of it. It should be very simple, we only need a few things for our canonical helper. So maybe something like this:

  def canonical_href
    "https://era.library.ualberta.ca/#{request_path}"
  end

  private

  def request_path
    return '' if request.path == '/'

    request.path
  end

Which is great, saves us from depending on another gem 😄

Will look into this more when I tackle the issue.

murny added a commit that referenced this issue Feb 6, 2020
murny added a commit that referenced this issue Feb 6, 2020
murny added a commit that referenced this issue Feb 6, 2020
murny added a commit that referenced this issue Feb 13, 2020
@murny
Copy link
Contributor Author

murny commented Feb 13, 2020

This is now merged into master. Closing out issue

@murny murny closed this as completed Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants