Models, controllers, and code reuse
- by user11715
I have a blog where users can post comments.
When creating a comment, various things happen:
creating the comment object, associations, persisting
sending notification emails to post's author given his preferences
sending notification to moderators given their preferences
updating a fulltext database for search
...
I could put all this in the controller, but what if I want to reuse this code ? e.g. I would like to provide an API for posting comments.
I could also put this in the model, but I wonder if I won't lose flexibility by doing so. And would it be acceptable to do all of this from the model layer ?
What would you do ?