moiristo / deep_cloneable

This gem gives every ActiveRecord::Base object the possibility to do a deep clone that includes user specified associations.
MIT License
785 stars 89 forks source link

Rails 6 Active Storage Full Copy #118

Closed rossinkiwi closed 4 years ago

rossinkiwi commented 4 years ago

The example in the README should be a little different for Rails 6. Active Storage Full copy example code:

pirate.deep_clone include: :parrot do |original, kopy|
  if kopy.is_a?(Pirate) && original.avatar.attached?
    original.avatar.open do |tempfile|
      kopy.avatar.attach({
        io: File.open(tempfile.path),
        filename: original.avatar.blob.filename,
        content_type: original.avatar.blob.content_type
      })
    end
  end
end
moiristo commented 4 years ago

Thanks!