Topic: Creating x amount of other models after creating one

Hello guys,

I am pretty new to rails and I have been googling for some time but there is not that much specific information out there (maybe I also don't know how to find it)

Anyways right now I am working on this small project that calculates your stock VALUE each and every year according to the intress you enter on the form. So lets say if you have following values:
value = 100
intress = 10
years = 5

Then the output should be following:

Now I can print out the output but what makes this task a little harder is that I want to save each and every value to a SEPERATE TABLE which means that I have basically two tables. A STOCK table and a VALUE table. And of course a foreign key is in the value table to connect the stock with the values.

I have done some code already but right now I have been stuck for one day in the place where I have to save x(years) amount  of values calculated to the VALUE table AFTER saving the stock to the STOCK table. So basically creating x amount of VALUE models after creating STOCK model.

Can you help me or do you have any suggestions?

Appreciate it! smile