[From the issue I opened about it: Organize models in subfolders · Issue #28152 · rails/rails · GitHub]
I don’t know if this is more a bug report or a feature request, or even an SO question
anyway:
I have a model Activity which has a lot of sti types, so a lot of related class files. I would like to organize them into app/models/activities, in order to separate them from the other models. I can actually accomplish it using config.eager_load_paths += %W(#{config.root}/app/models/activities) directive, but then in development mode the following exception is raised:
ArgumentError: A copy of SubFolderModel has been removed from the module tree but is still active!
I guess the reason is that app/models/subfolder conflicts with app/models autoload. Anyway, is there a way to organize models using different directories?
Steps to reproduce
- Create an
app/modelssubfolder - Put some models inside
- Add
config.eager_load_paths += %W(#{config.root}/app/models/subfolder)toconfig/application.rb - Start the application in development mode
Expected behavior
Everything works fine
Actual behavior
Sometimes the following exception is raised:
ArgumentError: A copy of SubFolderModel has been removed from the module tree but is still active!
System configuration
Rails version: 5.0.1
Ruby version: 2.4.0