This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.
Message originally sent by slack user U719UPXQ17B
Tried modularising an old rails app. Decided to put some parts in packages while the other parts are in the conventional rails format. After, i run packwerk check but started in run into the issues have detailed below.
Folder structure
- app
- controllers
- models
- mailers
- packages
- package_name
- app
- models
- controllers - spec
- app
- package_name
added to config/application.rb
config.autoload_paths += Dir[Rails.root / "app/packages/*/app/*"]
config.autoload_paths += Dir[Rails.root / "app/packages/*/spec/*"]
config.autoload_paths += Dir[Rails.root / "lib"]
On running packwerk check you get this error We could not extract autoload paths from your Rails app. This is likely a configuration error. (RuntimeError)
When i run bin/rails zeitwerk:check
, it indicates that the files in the packages needs to be eagerly loaded. When i do that, i get NameError: uninitialized constant
for some files.