I've been digging into the discussion around nested mass assignment,
and am trying my hand at a plugin that adds what I consider the
optimal model behavior. But I'm running into a solid problem trying to
use association proxies without modifying anything in the database.
My take is that there should be three very discrete phases to
updating: assignment, validation, and saving. Right now this is
somewhat mixed, because _certain_ assignments will touch the database.
Could this change? Besides being a general improvement (I think), it
would be very helpful for nested mass assignment.
@user = User.find(params[:id])
@user.attributes = params[:user]
render :action => 'edit'.
Right now the `@user.address.build' would disassociate (or destroy) an
existing address, even if the @user was ultimately invalid and the new
address was not saved. What I would like to see is for assigning (or
building) a new address to make in-memory changes that are queued up
for the final #save transaction. The association proxies, instead of
updating the database, could shuffle records into arrays where the
save method picked up on them and took the final action ... in a
That is, I would like to see the #save method ultimately work
something like this:
I'm sure it would be a bit trickier than that (especially with new
records and ids), but what do y'all think of the direction? This is
something I would work on, perhaps with a bit of assistance.