Closed acetinick closed 1 week ago
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.
Rails achieves this by
1) presence or absence of an id
, and
2) an update_only
flag.
https://api.rubyonrails.org/v7.1.3.4/classes/ActiveRecord/NestedAttributes/ClassMethods.html
An implementation like that would keep with active record api expectations.
Likely gonna be addressed by #180
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.