public-activity / public_activity

Easy activity tracking for models - similar to Github's Public Activity
MIT License
2.96k stars 334 forks source link

Cannot track changes for update action #391

Closed noctivityinc closed 3 weeks ago

noctivityinc commented 1 month ago

I understand that this is not the paper_clip gem, but it would be nice to always save the saved_changes hash as a parameter every time I update a record that is tracked.

Unfortunately, I can't seem to find a way to do this. I tried adding:

tracked parameters: :tracked_attributes

def tracked_attributes
    changed_attributes  # as well as saved_changes
end

and even tried overriding the PublicActivity::Update method but nothing seems to work. How can I easily store the changes hash as a parameter for all tracked updates?

noctivityinc commented 3 weeks ago

For anyone wanting to do this still, I got this to work:

tracked owner: proc { |controller, model| controller&.send :current_account }, params: { changes: proc { |c, m| m.saved_changes.except(:updated_at).to_h } }