Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8667e4c2
Commit
8667e4c2
authored
Feb 29, 2020
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add initializers that run before Zeitwerk
We need this to setup inflections that Zeitwerk needs
parent
a797fdfa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
0 deletions
+24
-0
config/application.rb
config/application.rb
+7
-0
config/initializers_before_autoloader/000_inflections.rb
config/initializers_before_autoloader/000_inflections.rb
+0
-0
doc/development/README.md
doc/development/README.md
+1
-0
doc/development/rails_initializers.md
doc/development/rails_initializers.md
+16
-0
No files found.
config/application.rb
View file @
8667e4c2
...
@@ -292,6 +292,13 @@ module Gitlab
...
@@ -292,6 +292,13 @@ module Gitlab
initializer
:move_initializers
,
before: :load_config_initializers
,
after: :let_zeitwerk_take_over
do
initializer
:move_initializers
,
before: :load_config_initializers
,
after: :let_zeitwerk_take_over
do
end
end
# We need this for initializers that need to be run before Zeitwerk is loaded
initializer
:before_zeitwerk
,
before: :let_zeitwerk_take_over
,
after: :prepend_helpers_path
do
Dir
[
Rails
.
root
.
join
(
'config/initializers_before_autoloader/*.rb'
)].
sort
.
each
do
|
initializer
|
load_config_initializer
(
initializer
)
end
end
config
.
after_initialize
do
config
.
after_initialize
do
Rails
.
application
.
reload_routes!
Rails
.
application
.
reload_routes!
...
...
config/initializers
/
0_inflections.rb
→
config/initializers
_before_autoloader/00
0_inflections.rb
View file @
8667e4c2
File moved
doc/development/README.md
View file @
8667e4c2
...
@@ -97,6 +97,7 @@ Complementary reads:
...
@@ -97,6 +97,7 @@ Complementary reads:
-
[
Issue types vs first-class types
](
issue_types.md
)
-
[
Issue types vs first-class types
](
issue_types.md
)
-
[
Application limits
](
application_limits.md
)
-
[
Application limits
](
application_limits.md
)
-
[
Redis guidelines
](
redis.md
)
-
[
Redis guidelines
](
redis.md
)
-
[
Rails initializers
](
rails_initializers.md
)
## Performance guides
## Performance guides
...
...
doc/development/rails_initializers.md
0 → 100644
View file @
8667e4c2
# Rails initializers
By default, Rails loads Zeitwerk after the initializers in
`config/initializers`
are loaded.
Autoloading before Zeitwerk is loaded is now deprecated but because we use a lot of autoloaded
constants in our initializers, we had to move the loading of Zeitwerk earlier than these
initializers.
A side-effect of this is that in the initializers,
`config.autoload_paths`
is already frozen.
To run an initializer before Zeitwerk is loaded, you need put them in
`config/initializers_before_autoloader`
.
Ruby files in this folder are loaded in alphabetical order just like the default Rails initializers.
Some examples where you would need to do this are:
1.
Modifying Rails'
`config.autoload_paths`
1.
Changing configuration that Zeitwerk uses, e.g. inflections
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment