4 ms·
I like it too, and have this line of code in a few apps. It's not technically right because, in MVC, your business logic belongs in your models. Imagine a situ
by breckenedge 14y ago
I like it too, and have this line of code in a few apps. It's not technically right because, in MVC, your business logic belongs in your models.
Imagine a situation where you want to bulk-create Users via script (or, simply, not via your controller "create" action). Shouldn't those bulk-created users get emails too? It depends on your business logic, hence, your model.
- bradwestness 14y agoWell, the business logic that the given model is responsible for belongs in the model. For instance, calculating an order total belongs in the Order model if you are building a shopping cart. However, you shouldn't break separation of concerns just to keep 100% of the business logic inside your object models. Having tightly coupled objects that depend on other classes in your application that you wouldn't expect is worse than having a little bit of business logic in your controller (or some service object), in my opinion.