Is the reason that both update_all and write_attributes are being used because update_all might filter out attributes that cannot be mass assigned, while write_attributes can work around mass assignment restrictions?

If so, then I think write_attributes should be used exclusively. Some people (myself included) use a mass assignment security object that throws exceptions rather than simply logging errors. That can result in problems if internals such as this are not careful to avoid triggering mass assignment issues in cases where the input is controlled (and not arbitrary, unsafe input).

Also, it seems like it's necessary to call document.save after using write_attributes, because write_attributes does not result in a save on its own...