title: Summing up data from tables Ruby on Rails
body: <p>What I have is a website where I add collected data of every single shift in a factory's production lines. I add data like (Quantity in tonnes). What I want is to be able to have the data of for instance; the morning, late and night shift of the (Quantity in tonnes) which are in the Shift table and are present and visible in the Shift Index view all combined and added, and added in another page which is the Days Index page (Day contains the shifts, one day has 3 shifts), so I could see the 3 shifts' data summed up together into the data combined to see as the total output of the day.</p>
  
  <p>For example, in the "Quantity in tonnes", I would like 7 + 10 + 12 (These are the inputs I already have and I have added through a form to the shifts index) to be summed up, and appear in the Days index page automatically without me interfering as "29" in the Quantity of tonnes columns in it.</p>
  
  <p><img src="https://i.stack.imgur.com/YUbFb.png" alt="Shifts Index View"></p>
  
  <p><img src="https://i.stack.imgur.com/DkcU3.png" alt="Days Index View"></p>
  
  <p>How is that possible to do? I can't seem to figure out how to write the code for it so that it would loop over all the inputs and constantly give me the summed out outputs.</p>
  
  <p>Let me know if you need to see any parts of my code and if there is anymore info I could add for you to understand.</p>