Skip to content

Commit

Permalink
Edits in example code and railties CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Mar 6, 2023
1 parent d0d9e8e commit 779c14b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions guides/source/autoloading_and_reloading_constants.md
Expand Up @@ -507,10 +507,10 @@ Zeitwerk supports [custom root namespaces](https://github.com/fxn/zeitwerk#custo
#
# In this example we define the module on the spot. Could also be created
# elsewhere and its definition loaded here with an ordinary `require`. In
# any case, `push_dir` expects a class or module object as second argument.
# any case, `push_dir` expects a class or module object.
module Services; end

Rails.autoloaders.main.push_dir("#{Rails.root}/app/services", Services)
Rails.autoloaders.main.push_dir("#{Rails.root}/app/services", namespace: Services)
```

Applications running on Rails < 7.1 have to additionally delete the directory from `ActiveSupport::Dependencies.autoload_paths`. Just add this line to the same file:
Expand Down
8 changes: 3 additions & 5 deletions railties/CHANGELOG.md
Expand Up @@ -11,15 +11,13 @@
#
# In this example we define the module on the spot. Could also be created
# elsewhere and its definition loaded here with an ordinary `require`. In
# any case, `push_dir` expects a class or module object as second argument.
# any case, `push_dir` expects a class or module object.
module Services; end

Rails.autoloaders.main.push_dir("#{Rails.root}/app/services", Services)
Rails.autoloaders.main.push_dir("#{Rails.root}/app/services", namespace: Services)
```

Before this change, Rails would later override the configuration. You had to
delete `app/services` from `ActiveSupport::Dependencies.autoload_paths` as
well.
Check the autoloading guide for further details.

*Xavier Noria*

Expand Down

0 comments on commit 779c14b

Please sign in to comment.