Skip to content

Commit 7c037c4

Browse files
committed
Update reload documentation
refs #358
1 parent e159a1e commit 7c037c4

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

README.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137
- [Reloading API Changes in Development](#reloading-api-changes-in-development)
138138
- [Reloading in Rack Applications](#reloading-in-rack-applications)
139139
- [Reloading in Rails Applications](#reloading-in-rails-applications)
140+
- [Rails 7+ (Zeitwerk)](#rails-7-zeitwerk)
141+
- [Rails 6 and Earlier](#rails-6-and-earlier)
140142
- [Performance Monitoring](#performance-monitoring)
141143
- [Active Support Instrumentation](#active-support-instrumentation)
142144
- [Hook Points](#hook-points)
@@ -4079,6 +4081,25 @@ Use [grape-reload](https://github.com/AlexYankee/grape-reload).
40794081

40804082
### Reloading in Rails Applications
40814083

4084+
#### Rails 7+ (Zeitwerk)
4085+
4086+
Rails 7+ uses [Zeitwerk](https://github.com/fxn/zeitwerk) as the default autoloader, which automatically handles reloading of code in development mode without any additional configuration.
4087+
4088+
If your API files are in `app/api`, Zeitwerk will automatically autoload and reload them. No additional configuration is needed.
4089+
4090+
If you encounter issues with reloading, ensure that:
4091+
4092+
1. Your API files follow Zeitwerk naming conventions (file names should match class names).
4093+
2. The `config.enable_reloading` is set to `true` in `config/environments/development.rb` (this is the default).
4094+
4095+
For troubleshooting autoloading issues, have a look at the [Rails documentation](https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#troubleshooting).
4096+
4097+
See the [Rails Autoloading and Reloading Constants guide](https://guides.rubyonrails.org/autoloading_and_reloading_constants.html) for more information.
4098+
4099+
#### Rails 6 and Earlier
4100+
4101+
For Rails versions before 7, you need to configure reloading manually.
4102+
40824103
Add API paths to `config/application.rb`.
40834104

40844105
```ruby
@@ -4097,28 +4118,12 @@ if Rails.env.development?
40974118
api_reloader = ActiveSupport::FileUpdateChecker.new(api_files) do
40984119
Rails.application.reload_routes!
40994120
end
4100-
ActionDispatch::Callbacks.to_prepare do
4121+
ActiveSupport::Reloader.to_prepare do
41014122
api_reloader.execute_if_updated
41024123
end
41034124
end
41044125
```
41054126

4106-
For Rails >= 5.1.4, change this:
4107-
4108-
```ruby
4109-
ActionDispatch::Callbacks.to_prepare do
4110-
api_reloader.execute_if_updated
4111-
end
4112-
```
4113-
4114-
to this:
4115-
4116-
```ruby
4117-
ActiveSupport::Reloader.to_prepare do
4118-
api_reloader.execute_if_updated
4119-
end
4120-
```
4121-
41224127
See [StackOverflow #3282655](http://stackoverflow.com/questions/3282655/ruby-on-rails-3-reload-lib-directory-for-each-request/4368838#4368838) for more information.
41234128

41244129
## Performance Monitoring

0 commit comments

Comments
 (0)