I have a model named Box and it has X and Y attributes. When I’m editing the Room model (which has_many boxes) I’m displaying all the boxes at their coordinates and the user can drag the boxes around, add some new boxes and remove some existing boxes.
Now when the user clicks “Save” I want to :
- update the Boxes table and save the new positions for the corresponding boxes.
- save new added boxes into the database
- delete removed boxes from the database
How can I complete this ?
I’ve solved the problem using hidden fields which I’m completing at runtime and submitting them through the form