I am working on a large(ERP level) Rails project. We have 150 tables and more than 150 models. It takes minutes to find a model. Should we add all models under the models folder or should we put them in different subfolders? Same thing goes for controllers and views.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
I think you are running into the limitations of a single Rails application. Much like having too much code in one module, it sounds like you have too many modules in one application.
You should consider breaking it up into multiple applications using a service model, or you might also go the route of plugins or even better look at the new Engine framework.
This will benefit you multiple ways. It will force you to exercise good encapsulation and have good testable interface points between pieces.
I don't think it is necessary.
I would also analyze the current performance issue further. Just having 150 models/tables should not cause more than a fraction of a second to be able to find and use the model! Is it actually the db query itself that takes a long time (when not cached)? That can be addressed in many ways (splitting data, aggregating data, adding indexes, changing queries to be more performant, etc.
You may or may not need to do controllers and views under separate directories.
To access things arranged this way you just use