Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveStorage get dirty object stating if an image as changed

I would like to know if an image has changed on an ActiveRecord model object so I can perform other functions but don't see anything available to know this.

I.E.

object.image.changed? or object.image_changed? or object.changed? 
like image 536
John Pollard Avatar asked Apr 11 '18 19:04

John Pollard


1 Answers

If you would like to know before the object has saved:

object.attachment_changes.any?

If you would like to know after the changes having been committed, the only solution I've found so far is to check the blob:

object.image.blob.saved_changes?

like image 141
Dan Avatar answered Oct 27 '22 01:10

Dan