Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CarrierWave rake task to reprocess images for an object
# CarrierWave rake tasks
#
# Task: reprocess
# Desc: Reprocess all images for a given class
# Usage: rake carrierwave:reprocess class=<ClassName> mount_uploader=<mount_uploader>
namespace :carrierwave do
task :reprocess, [:class, :mount_uploader] => :environment do |task, args|
desc "Reprocess all images for a given class."
args[:class].constantize.all.each do |object|
begin
object.update_attribute(args[:mount_uploader].to_sym, object.instance_eval(args[:mount_uploader]))
rescue
false
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment