4

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 controller 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?

mjleitch
  • 41
  • 1

2 Answers2

2

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.

robbrit
  • 17,560
  • 4
  • 48
  • 68
0

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

Matthew Nessworthy
  • 1,428
  • 10
  • 19