Skip to content

Commit bd19260

Browse files
Adjust STI preloading docs to run loader collapse also when eager loading
Zeitwerk should still apply collapsing in option #2 of handling STI (Preload a collapsed directory) when eager loading the application, because the collapsing prevents the undesired namespace to be defined. Also when eager loading the application, you don't want that namespace.
1 parent d440ba7 commit bd19260

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

guides/source/autoloading_and_reloading_constants.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,10 @@ In this example, we still want `app/models/shapes/circle.rb` to define `Circle`,
359359
```ruby
360360
# config/initializers/preload_stis.rb
361361

362+
shapes = "#{Rails.root}/app/models/shapes"
363+
Rails.autoloaders.main.collapse(shapes) # Not a namespace.
364+
362365
unless Rails.application.config.eager_load
363-
shapes = "#{Rails.root}/app/models/shapes"
364-
Rails.autoloaders.main.collapse(shapes) # Not a namespace.
365366
Rails.application.config.to_prepare do
366367
Rails.autoloaders.main.eager_load_dir(shapes)
367368
end

0 commit comments

Comments
 (0)