aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2019-07-12 23:50:10 +0200
committerXavier Noria <fxn@hashref.com>2019-07-12 23:50:10 +0200
commitdd110e472024643452383f4195b1919f5aa7b249 (patch)
treeac2abb1febb96cceb32afb6952ab540e5a1301de /guides
parent938d18d09a40f65e5366d97f8df7bede604f7070 (diff)
downloadrails-dd110e472024643452383f4195b1919f5aa7b249.tar.gz
rails-dd110e472024643452383f4195b1919f5aa7b249.tar.bz2
rails-dd110e472024643452383f4195b1919f5aa7b249.zip
simplifies Zeitwerk compat instructions in upgrading guide [skip ci]
Diffstat (limited to 'guides')
-rw-r--r--guides/source/upgrading_ruby_on_rails.md40
1 files changed, 5 insertions, 35 deletions
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index 123f8dce80..5e40f47df5 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -184,46 +184,16 @@ That may be handy if you need to preload STIs or configure a custom inflector, f
If the application being upgraded autoloads correctly, the project structure should be already mostly compatible.
-However, `classic` mode infers file names from missing constant names (`underscore`), whereas `zeitwerk` mode infers constant names from file names (`camelize`). These helpers are not always inverse of each other, in particular if acronyms are involved. For instance, `"FOO".underscore` is `"foo"`, but `"foo".camelize` is `"Foo"`, not `"FOO"`. Compatibility can be checked by setting `classic` mode first temporarily:
+However, `classic` mode infers file names from missing constant names (`underscore`), whereas `zeitwerk` mode infers constant names from file names (`camelize`). These helpers are not always inverse of each other, in particular if acronyms are involved. For instance, `"FOO".underscore` is `"foo"`, but `"foo".camelize` is `"Foo"`, not `"FOO"`.
-```ruby
-# config/application.rb
-
-config.load_defaults "6.0"
-config.autoloader = :classic
-```
-
-and then running
-
-```
-bin/rails zeitwerk:check
-```
-
-When all is good, you can delete `config.autoloader = :classic`.
+Compatibility can be checked with the `zeitwerk:check` task:
-That checker may technically be fooled in some rare cases, but it works well in practice for projects that are running correctly in a previous versions of Rails and are being upgraded. This task tries to print a helpful report.
-
-If that check is good, we recommend to do a second one, more strict: Eager load the application in `zeitwerk` mode. In order to do that, enable eager loading in `development` mode:
-
-```ruby
-# config/initializers/development.rb
-config.eager_load = true
```
-
-and boot the application:
-
-```ruby
-bin/rails runner 1
+$ bin/rails zeitwerk:check
+Hold on, I am eager loading the application.
+All is good!
```
-If a file does not match the constant it defines, you'll get a raw `NameError` explaining the discrepancy:
-
-```
-expected file ... to define constant ..., but didn't (NameError)
-```
-
-Once all is good, you'll just get a prompt back. Remember to disable `config.eager_load`, it it was false before.
-
#### require_dependency
All known use cases of `require_dependency` have been eliminated, you should grep the project and delete them.