views:

113

answers:

0

I have a has_many association, and a UI that uses javascript to dynamically add/remove as many has_many items as the user wants. After they are done, they hit save, which would call update on the parent. When I do this, the child items do not have any IDs, and the controller does not know how to handle it, so it just ignores it. How can I get the controller to realize that there are some new child items, and to save those when the parent is updated?

I.E: Car currently has Door1,Door2,Door3

User dynamically adds Door4 and Door5 using javascript on UI, but there are no IDs.

User clicks on save, which calls the update method for car. Car does not save door4 and door5.