diff options
author | Xavier Noria <fxn@hashref.com> | 2019-05-12 17:01:05 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2019-05-12 17:01:57 +0200 |
commit | 8f9f43172c9b12e363b56b2fad35f904224e9616 (patch) | |
tree | 2e33c3223a609b38e0fbf46682f39664e4f1562a /guides/source | |
parent | 65f9e0c4bbc56f208cb6b2329d890c6d9935da1d (diff) | |
download | rails-8f9f43172c9b12e363b56b2fad35f904224e9616.tar.gz rails-8f9f43172c9b12e363b56b2fad35f904224e9616.tar.bz2 rails-8f9f43172c9b12e363b56b2fad35f904224e9616.zip |
upgrading docs: one file => one constant [ci skip]
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/upgrading_ruby_on_rails.md | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index 76ee5c0c48..fee433dcfc 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -281,6 +281,35 @@ won't work, child objects like `Hotel::Pricing` won't be found. This restriction only applies to explicit namespaces. Classes and modules not defining a namespace can be defined using those idioms. +#### One file, one constant (at the same top-level) + +In `classic` mode you could technically define several constants at the same top-level and have them all reloaded. For example, given + +```ruby +# app/models/foo.rb + +class Foo +end + +class Bar +end +``` + +while `Bar` could not be autoloaded, autoloading `Foo` would mark `Bar` as autoloaded too. This is not the case in `zeitwerk` mode, you need to move `Bar` to its own file `bar.rb`. One file, one constant. + +This affects only to constants at the same top-level as in the example above. Inner classes and modules are fine. For example, consider + +```ruby +# app/models/foo.rb + +class Foo + class InnerClass + end +end +``` + +If the application reloads `Foo`, it will reload `Foo::InnerClass` too. + #### Spring and the `test` Environment Spring reloads the application code if something changes. In the `test` environment you need to enable reloading for that to work: |