Hello,
This is my first post here, so please be gently for me and excuse me my english
I was reading today about keeping controllers slim and moving validation rules to models but I don't know if I get it right. For simplicity, we have 2 models: users and posts.
Users can edit their posts, however each edit consumes a point. What do you think is the most natural way of validating this and why?
For me the most natural way would be:
In controller I can check if a post exists and belongs to user, if it doesn't just display a main page (no need for any fancy logic here since this situation shouldn't really happen). Here I can also check if user has enough points before even loading a model.
In model I can have form_validation rules for a post content/title and any other property.
That way If I introduce for example a control panel where as an admin I can edit every post, I can use that code and won't have to deal with "belongs to user/has enough points" rules (which wouldn't be applicable to admin account).
On the other hand, I could pass to edit method additional parameters and based on them have additional rules - that way I would keep everything inside Model.
What do you think is the right approach and why?
Thank you for any answers!