Read more

Carrierwave – Recreate versions

Deleted user #6
October 23, 2013Software engineer

A snippet of the carrierwave documentation Show archive.org snapshot

You might come to a situation where you want to retroactively change a version or add a new one. You can use the recreate_versions! method to recreate the versions from the base file. This uses a naive approach which will re-upload and process the specified version or all versions, if none is passed as an argument.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Call recreate_versions! on a mounted uploader.

A common usecase

User.all.each { |user| user.avatar.recreate_versions! if user.avatar? }

Caveats

  • recreate_versions! only processes :Symbol arguments. If you feed it strings, it will silently do nothing.
  • If your uploader dynamically generates the filename (e.g. by incorporating a user's name), you must call save afterwards, because recreate_versions! doesn't update the stored filename.
Posted to makandra dev (2013-10-23 11:15)