How do I duplicate a file stored in ActiveStorage in Rails 5.2

Update your model:

class Package < ApplicationRecord
  has_one_attached :poster_image
end

Attach the source package’s poster image blob to the destination package:

source_package.dup.tap do |destination_package|
  destination_package.poster_image.attach(source_package.poster_image.blob)
end

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)