Skip to content

Prepare initializers for Rails 6#4462

Merged
mitchellhenke merged 7 commits intomasterfrom
mitchellhenke/rails-6-prep-initializers-lg-3424
Nov 30, 2020
Merged

Prepare initializers for Rails 6#4462
mitchellhenke merged 7 commits intomasterfrom
mitchellhenke/rails-6-prep-initializers-lg-3424

Conversation

@mitchellhenke
Copy link
Contributor

@mitchellhenke mitchellhenke commented Nov 25, 2020

Autoloading in Rails 6 is getting stricter to fix some inconsistencies in how files are initially loaded and reloaded. The short version is anything used in an initializer can't be reloaded properly. More detailed descriptions are here and here.

This PR moves some of the code used in initializers to lib/, which is not reloaded, along with a few other fixes.

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-6-prep-initializers-lg-3424 branch from cd29e98 to 5f9858f Compare November 25, 2020 21:46
@mitchellhenke mitchellhenke changed the title Rails 6 prep initializers Prepare initializers for Rails 6 Nov 25, 2020
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new relic tracer moves are unfortunate, but I'm not sure we can reference model classes in initializers in the way we were previously.

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-6-prep-initializers-lg-3424 branch from 5f9858f to 6a7b521 Compare November 25, 2020 22:24
@mitchellhenke mitchellhenke marked this pull request as ready for review November 25, 2020 22:25
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM, a couple of small comments

IAL1 = 1
IAL2 = 2
IAL2_STRICT = 22
IAL_MAX = Idp::Constants::IAL_MAX
Copy link
Contributor

Choose a reason for hiding this comment

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

What if we removed the constants definitions here and updated refs to Identity::IAL1 etc to Idp::Constants::IAL1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I waffled on that, but will update to use Constants everywhere

Comment on lines +1 to +2
module Idp
module Constants
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make the file match autoloading expectations even if it's not autoloaded? lib/idp/constants.rb or IdpConstants as the module name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep

@vendors = nil

class << self
def validate_vendors!
Copy link
Contributor

Choose a reason for hiding this comment

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

@mitchellhenke mitchellhenke merged commit f733840 into master Nov 30, 2020
@mitchellhenke mitchellhenke deleted the mitchellhenke/rails-6-prep-initializers-lg-3424 branch November 30, 2020 16:06
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.

2 participants