Skip to content

Modifying marshaled attribute in place doesn't set dirty flag; not persisted #22

@troy

Description

@troy

This is logical but not obvious until one runs into it. Adding or updating a hash key in a marshaled attr_encrypted doesn't mark the attribute as dirty, so save will not update the database column.

Even calling encrypted_whatever_will_change! and then changing the attribute won't change the encrypted_whatever ciphertext. Turning off partial_updates for the model also makes no difference, presumably because attr_encryptor never receives the chance to update the ciphertext.

The only way I've found to work around this is to assign the model attribute for every change, like:

my_instance.important_stuff = important_stuff.merge(:newkey => newval)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions