1

I am migrating the attachments from paperclip to Active storage.

In paperclip, we can check whether the file is updated by using the active model dirty as below,

after_update_commit :notify_users, if: :saved_change_to_file_updated_at?

But in Active storage, how can we check whether the file is updated, Can anyone help on this?

Saranya
  • 41
  • 4

1 Answers1

0

You could try with attachment_changes. This method will return an object that specifies the changes made to each of your attachments.

after_update_commit do
  notify_users if attachment_changes['file'].present? # or maybe something more elaborate with some specific attribute
end
Dharman
  • 30,962
  • 25
  • 85
  • 135
meacuna
  • 191
  • 1
  • 1
  • 11