开发者

Which Controller to Use?

This is a "MVC best practices" question. I have a User model with a belongs to relationship with Child. I want to display a list of children for a specific user. I could access all children related to a single user through the view action within the users controller, or I could access them through an action in the children controll开发者_StackOverflow中文版er with a where clause with the user_id. Which would be the best practice? Handing things like this in the parent (users) controller? Or handling this in the children controller?


Since it has to do with a specific User but not a specific Child, I'd say it would be good to put it in the users controller as an action called children.


Either way is fine in my opinion. The most important thing is to be consistent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜