Updating several forms with one click of a button

21 views
Skip to first unread message

Tony Totals

unread,
Aug 4, 2018, 4:28:38 AM8/4/18
to Ruby on Rails: Documentation
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?

Xavier Noria

unread,
Aug 4, 2018, 4:35:09 AM8/4/18
to rubyonra...@googlegroups.com
Hi Tony,

This is a mailing list for Rails documentation.

This question could be asked in StackOverflow or the rubyonrails-talk mailing list, for example.

Reply all
Reply to author
Forward
0 new messages