You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently encountered an unexpected behaviour with transaction_changed_attributes.
I’m using ActiveRecord::Store, which provides the store_accessor method. This allows keys in a JSON column to be treated like regular attributes. For instance, in a model (let's call it Subscription), there’s a details JSON field that stores data like start_date and account_id. By defining accessors for these keys, they can be interacted with as normal attributes. More details can be found here
Issue
When updating the start_date nested field directly using:
the change is correctly captured in transaction_changed_attributes.
However, when updating the same field using the store_accessor method:
subscription.update!(start_date: "2019-10-23")
the change does not get captured in transaction_changed_attributes.
Question
This discrepancy becomes problematic when my logic relies on detecting these changes. Is this behaviour a known limitation, or could I be missing something? I’d greatly appreciate any insights or suggestions you might have!
The text was updated successfully, but these errors were encountered:
Hi @dylanahsmith @byroot ,
I recently encountered an unexpected behaviour with
transaction_changed_attributes
.I’m using ActiveRecord::Store, which provides the
store_accessor
method. This allows keys in a JSON column to be treated like regular attributes. For instance, in a model (let's call itSubscription
), there’s adetails
JSON field that stores data likestart_date
andaccount_id
. By defining accessors for these keys, they can be interacted with as normal attributes. More details can be found hereIssue
When updating the
start_date
nested field directly using:the change is correctly captured in
transaction_changed_attributes
.However, when updating the same field using the
store_accessor
method:the change does not get captured in
transaction_changed_attributes
.Question
This discrepancy becomes problematic when my logic relies on detecting these changes. Is this behaviour a known limitation, or could I be missing something? I’d greatly appreciate any insights or suggestions you might have!
The text was updated successfully, but these errors were encountered: