Reputation: 8986
I have a model called User
, and another called Run
. Each user have many runs. Duration and distance are attributes of Run.
I want to display on the user page, the sum of the distance and duration of his runs.
I'm not sure if this sum, i.e., total distance and total duration should be attributes of the user, or if it's should be calculated on the ViewProfileController
just in order to display it on his profile.
What would be the correct practice?
Upvotes: 0
Views: 55
Reputation: 1380
The sum of the user runs should be a method in the user model, because it's specific to each user.
Also, a best practice is to have skinny controllers and have fat models.
Upvotes: 4