DmitryTsepelev / store_model

Work with JSON-backed attributes as ActiveRecord-ish models

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

accepts_nested_attributes_for allow partial updates

acetinick opened this issue · comments

When using accepts_nested_attributes_for on models the JSON objects gets overidden completely with the next update that happens on the model.

eg. if you have two attributes in the store, and update each atrtibute using two separate forms, it will override the whole store with only the new attribute.

To fix this I have a override in my model, but feel it should be a default for the library.

image

Hey hey, good call! Wanna try to make a PR to make it work on the gem level? 🙂

Good call! At the same time, what do we do if we indeed want to override the whole hash with the new hash, e.g. delete some of the attributes? I was thinking about an attribute _partial that'd be passed with the hash, so it could indicate only partial update, but I don't like interfering with the original data.