How to remove dependents in has-many-belongs-to relationship before saving?


In my RESTful controller’s create method, how do I intercept and
modify any dependents before saving? That is, I have a model that is
the parent of nested associations gathered from a form. The first line
of this model’s controller create method is:

@parent =[:parent])

What if I want to tour through the nested associations and possibly
remove a few from the association before I proceed to save the parent
in the create method? All the discussion of removing association
models concerns the case when models have already been persisted to a
database, not before they’ve been saved. I’ve been fiddling around
with this, but can’t figure out a way to ‘delete’ associations while
they’re only in-memory.

(By way of background, I create multiple ‘rows’ representing each
nested association in my parent model form. I allow the case that the
user may submit the form with some of the nested association fields
being blank. In that case, however, I’d like to sidestep any
validations in those nested association models by removing the blank-y
dependent model objects before the parent is saved.)

Thanks for any comments,