Rails noob - How to work on data stored in models
- by Raghav Kanwal
I'm a beginner to Ruby and Rails, and I have made a couple applications like a Microposts clone and a Todo-List for starters, but I'm starting work on another project.
I've got 2 models - user and tracker, you log in via the username which is authenticated and you can log down data which is stored in the tracker table.
The tracker has a column named "Calories" and I would like Rails to sum all of the values entered if they are on the same date, and output the result which is subtracted from, say 3000 in a new statement after the display of the model. I know what I'm talking about is just ruby code, im just not sure how to incorporate it. :(
Could someone please guide me through this? And also link me to some guides/tutorials which teach working on data from models?
Thank you :)