Skip to content

Commit 8485888

Browse files
committed
docs: Add cause of UninitializedConstant error and fix formatting
1 parent eadb6dd commit 8485888

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

doc/troubleshooting.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,32 @@ This is related to autoloading via zeitwerk and the default assumptions made by
2929

3030
The usual culprits causing this are:
3131

32+
- A module is listed as the creator of a registry entry in registry_data.rb, but the module itself hasn't been created
3233
- Naming the file `person_names.rb` but naming the constant defined in the file `Personnames` (should be `PersonNames`)
3334
- Opposite of above: naming the file `personnames.rb` and the constant defined in the file `PersonNames` (should be `Personnames`)
3435
- Mismatch of file path hierarchy and constant hierarchy. For example, having file path `/Users/you/projectname/lib/project/jobs/name_cleanup_prep/person_names.rb` but the following in your file:
3536

36-
```
37+
~~~
3738
module Project
3839
module NameCleanupPrep
3940
module PersonNames
40-
end
41+
end
4142
end
4243
end
43-
```
44+
~~~
4445

4546
The "jobs" level of file hierarchy is expected to be represented in your module namespace hierarchy, like:
4647

47-
```
48+
~~~
4849
module Project
4950
module Jobs
5051
module NameCleanupPrep
5152
module PersonNames
52-
end
53+
end
5354
end
5455
end
5556
end
56-
```
57+
~~~
5758

5859
Zeitwerk provides ways to override almost all of this default behavior via inflectors, namespace collapsing, and techniques. See its very long README (linked above) for details. However, it's generally easier in most projects to follow the default convention (pretty simple once you are used to it) and reap the benefits of never having to `require_relative` anything ever again (a huge pain if you move files around or rename things).
5960

0 commit comments

Comments
 (0)