Skip to content

Commit

Permalink
documents how to troubleshoot autoloading in zeitwerk mode
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Aug 13, 2019
1 parent 5a70f33 commit 8ab4fd1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions guides/source/autoloading_and_reloading_constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,32 @@ class Triangle < Polygon
end
```

Troubleshooting
---------------

The best way to follow what the loaders are doing is to inspect their activity.

The easiest way to do that is to throw

```ruby
Rails.autoloaders.log!
```

to `config/application.rb` after loading the framework defaults. That will print traces to standard output.

If you prefer logging to a file, configure this instead:

```ruby
Rails.autoloaders.logger = Logger.new("#{Rails.root}/log/autoloading.log")
```

The Rails logger is still not ready in `config/application.rb`, but it is in initializers:

```ruby
# config/initializers/log_autoloaders.rb
Rails.autoloaders.logger = Rails.logger
```

Rails.autoloaders
-----------------

Expand Down

0 comments on commit 8ab4fd1

Please sign in to comment.