You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/source/classic_to_zeitwerk_howto.md
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,7 +162,7 @@ Hold on, I am eager loading the application.
162
162
All is good!
163
163
```
164
164
165
-
####Concerns
165
+
### Concerns
166
166
167
167
You can autoload and eager load from a standard structure like
168
168
@@ -175,7 +175,7 @@ In that case, `app/models/concerns` is assumed to be a root directory (because i
175
175
176
176
The `Concerns::` namespace worked with the classic autoloader as a side-effect of the implementation, but it was not really an intended behavior. An application using `Concerns::` needs to rename those classes and modules to be able to run in `zeitwerk` mode.
177
177
178
-
####Having `app` in the autoload paths
178
+
### Having `app` in the autoload paths
179
179
180
180
Some projects want something like `app/api/base.rb` to define `API::Base`, and add `app` to the autoload paths to accomplish that in `classic` mode.
181
181
@@ -188,7 +188,7 @@ If you want to keep that structure, you'll need to delete the subdirectory from
Every element of `config.autoload_paths` should represent the top-level namespace (`Object`) and they cannot be nested in consequence (with the exception of `concerns` directories explained above).
265
+
266
+
To fix this, just remove the wildcards:
267
+
268
+
```ruby
269
+
config.autoload_paths <<"#{config.root}/lib"
270
+
```
271
+
272
+
### Spring and the `test` Environment
257
273
258
274
Spring reloads the application code if something changes. In the `test` environment you need to enable reloading for that to work:
259
275
@@ -270,7 +286,7 @@ reloading is disabled because config.cache_classes is true
270
286
271
287
This has no performance penalty.
272
288
273
-
####Bootsnap
289
+
### Bootsnap
274
290
275
291
Please make sure to depend on at least Bootsnap 1.4.4.
276
292
@@ -310,22 +326,6 @@ RSpec.describe "Zeitwerk compliance" do
Every element of `config.autoload_paths` should represent the top-level namespace (`Object`) and they cannot be nested in consequence (with the exception of `concerns` directories explained above).
0 commit comments