Posted almost 8 years ago. Visible to the public.

Carrierwave – Recreate versions

A snippet of the carrierwave documentation

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.

Call recreate_versions! on a mounted uploader.

A common usecase

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


  • 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.

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Owner of this card:

Martin Straub
Last edit:
almost 4 years ago
by Arne Hartherz
images, reprocess
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Martin Straub to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more