Nested relations are the death of Object Oriented Programming

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at:

Last winter made fun of a Python team for wasting time trying to figure out how to handle deeply nested relations. They were slowly groping their way toward a graph database solution, which seems to be the route that most end up taking, given enough years and enough pain. This seems to be an area where Object Oriented Programming clearly fails.

And yet, many smart folk continue to try. Ruby’s Reform:

Syncing Back

After validation, you have two choices: either call #save and let Reform sort out the rest. Or call #sync, which will write all the properties back to the model. In a nested form, this works recursively, of course.

It’s then up to you what to do with the updated models – they’re still unsaved.

Saving Forms

The easiest way to save the data is to call #save on the form.

if @form.validate(params[:song]) #=> populates album with incoming data
# by calling @form.album.title=.
# handle validation errors.

This will sync the data to the model and then call

Sometimes, you need to do saving manually.