In the sidekiq documentation, there is this quote about preferring to use /app/lib
instead of /lib
in Rails projects related to autoloading errors:
A lib/ directory will only cause pain. Move the code to app/lib/ and make sure the code inside follows the class/filename conventions.
Additionally, there is also:
Don't configure extra paths in autoload_paths or eager_load_paths. That's a hack; follow the conventions! Any directory underneath app/ may contain Ruby code, you don't need to explicitly configure anything.
My questions are:
Is there any truth to these statements that using /app/lib
is better than /lib
?
Is this only helpful for autoloading Rails-related objects (such as AR models, controllers, jobs, etc)? Or will it also help POROs?
Is there only a specific context in which these comments make sense?
lib
folder. I wouldn't try to make autoloading working with thelib
folder. I would always use an explicitrequire
to load features from thelib
folder. – Denary