Skip to content

Instantly share code, notes, and snippets.

@Vchekryzhov
Created February 13, 2019 15:50
Show Gist options
  • Save Vchekryzhov/7af3a0e65b0d67573cdac96ad0f25850 to your computer and use it in GitHub Desktop.
Save Vchekryzhov/7af3a0e65b0d67573cdac96ad0f25850 to your computer and use it in GitHub Desktop.
carrierwave recreate
YourModel.find_each do |ym|
begin
ym.process_your_uploader_upload = true # only if you use carrierwave_backgrounder
ym.your_uploader.cache_stored_file!
ym.your_uploader.retrieve_from_cache!(ym.your_uploader.cache_name)
ym.your_uploader.recreate_versions!(:version1, :version2)
ym.save!
rescue => e
puts "ERROR: YourModel: #{ym.id} -> #{e.to_s}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment