Unable to delete images from S3

12 Views Asked by At

I am using an S3 bucket to store images in my rails application. I have no issues uploading images. However, when I delete an instance of a model where I have defined the following:

  • has_many_attached :images, dependent: :destroy

the images are not being deleted in S3. In the #destroy action of my controller I have to explicitly call @instance_variable.images.each(&:purge).

What am I doing wrong?

I tried using the rails console but the outcome was the same. Calling destroy on the instance variable destroyed the instance from the database but not the images in the S3 bucket. However, calling purge directly on the images removed them from the bucket.

0

There are 0 best solutions below