3 ms·
Say you're writing an app that has simple business logic. Easy, you put that logic into model. Then you realize you need to write much more business logic code.
by Void_ 15y ago
Say you're writing an app that has simple business logic. Easy, you put that logic into model. Then you realize you need to write much more business logic code. No problem, model. But your model classes are getting fat and it looks ugly. So you refactor the code into modules.
Now somebody is browsing your code and they are ripping their hair off, because there's a method on Order object and there are 6 modules included in the Order object.
Before you realize it, you're violating not only MVC but also OOP.
If you used Services, you could model nice controller/manager classes in OOP manner, with responsibilities nicely distributed. These are your controllers. Rails controllers are just the HTTP interface.
- judofyr 15y agoI'm not suggesting that you should create modules and include these into your ActiveRecord-models. Feel free to create any kind of class/module/object/whatever, but as long it's related to the business logic put it under app/models.
- saturnflyer 15y ago+1 app/models is for domain models