module ViewModel::ActiveRecord::NestedControllerBase

def write_association(serialize_context: new_serialize_context, deserialize_context: new_deserialize_context, lock_owner: nil)

safe to use update hashes directly.
single parent each child can only appear once. This means it's
There's no multi membership, so when viewing the children of a

viewmodels directly.
This method always takes direct update hashes, and returns
def write_association(serialize_context: new_serialize_context, deserialize_context: new_deserialize_context, lock_owner: nil)
  require_external_referenced_association!
  association_view = nil
  pre_rendered = owner_viewmodel.transaction do
    update_hash, refs = parse_viewmodel_updates
    update_hash =
      ViewModel::ActiveRecord.add_reference_indirection(
        update_hash,
        association_data: association_data,
        references:       refs,
        key:              'write-association',
      )
    owner_view = owner_viewmodel.find(owner_viewmodel_id, eager_include: false, lock: lock_owner)
    association_view = owner_view.replace_associated(association_name, update_hash,
                                                     references: refs,
                                                     deserialize_context: deserialize_context)
    ViewModel::Callbacks.wrap_serialize(owner_view, context: serialize_context) do
      child_context = owner_view.context_for_child(association_name, context: serialize_context)
      ViewModel.preload_for_serialization(association_view)
      association_view = yield(association_view) if block_given?
      prerender_viewmodel(association_view, serialize_context: child_context)
    end
  end
  render_json_string(pre_rendered)
  association_view
end