I have been looking through the documentation on rails for a way to update four different models inside one function. My user model has_many clients. These clients has_many wagers. Once the wagers net result is computed in an integer, I need to update the User form and debit/credit a bank account figure and also update the client's form and debit/credit their available funds.
I put all the forms inside of a js function that was linked to a button like this: function(){ formA.submit formB.submit formC.submit}. What happens is only the first form is submitted and when the page refreshes after the first save, the code breaks and the other forms are not updated.
How can I update the forms of more than one model with a single click of the button by the user?