You need to pass the autoload symbol (perhaps a typo in your question) and call it the constant's parent, for example:
App.autoload :ModuleA, "app/module_a"
Note that this also works for nested levels. Let's say that in app/module_a you have:
module App::ModuleA autoload :Inner, "path/to/inner" end
When Ruby encounters App::ModuleA::Inner , it will first try to access ModuleA , succeed at startup, and only then try to execute Inner , which will succeed, since it now knows where its startup is.
Marc-andrΓ© lafortune
source share