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
-[Active Support Instrumentation](#active-support-instrumentation)
142
143
-[Hook Points](#hook-points)
@@ -4079,6 +4080,25 @@ Use [grape-reload](https://github.com/AlexYankee/grape-reload).
4079
4080
4080
4081
### Reloading in Rails Applications
4081
4082
4083
+
#### Rails 7+ (Zeitwerk)
4084
+
4085
+
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.
4086
+
4087
+
If your API files are in `app/api`, Zeitwerk will automatically autoload and reload them. No additional configuration is needed.
4088
+
4089
+
If you encounter issues with reloading, ensure that:
4090
+
4091
+
1. Your API files follow Zeitwerk naming conventions (file names should match class names).
4092
+
2. The `config.enable_reloading` is set to `true` in `config/environments/development.rb` (this is the default).
4093
+
4094
+
For troubleshooting autoloading issues, have a look at the [Rails documentation](https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#troubleshooting).
4095
+
4096
+
See the [Rails Autoloading and Reloading Constants guide](https://guides.rubyonrails.org/autoloading_and_reloading_constants.html) for more information.
4097
+
4098
+
#### Rails 6 and Earlier
4099
+
4100
+
For Rails versions before 7, you need to configure reloading manually.
4101
+
4082
4102
Add API paths to `config/application.rb`.
4083
4103
4084
4104
```ruby
@@ -4097,28 +4117,12 @@ if Rails.env.development?
4097
4117
api_reloader =ActiveSupport::FileUpdateChecker.new(api_files) do
4098
4118
Rails.application.reload_routes!
4099
4119
end
4100
-
ActionDispatch::Callbacks.to_prepare do
4120
+
ActiveSupport::Reloader.to_prepare do
4101
4121
api_reloader.execute_if_updated
4102
4122
end
4103
4123
end
4104
4124
```
4105
4125
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
-
4122
4126
See [StackOverflow #3282655](http://stackoverflow.com/questions/3282655/ruby-on-rails-3-reload-lib-directory-for-each-request/4368838#4368838) for more information.
0 commit comments