Created
September 16, 2014 11:58
-
-
Save nicolas-brousse/c9077a82add06888b27e to your computer and use it in GitHub Desktop.
Rake Tasks for Carrier Wave for reprocessing versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :carrierwave do | |
desc 'Reprocesses Carrier Wave file versions of a given model.' | |
task reprocess_all: :environment do | |
ActiveRecord::Base.descendants.each do |m| | |
next if m.uploaders.empty? | |
puts "Reprocess #{m.name}" | |
m.all.each do |entry| | |
m.uploaders.each do |uploader_name, uploader| | |
image = entry.method(uploader_name).call | |
next if image.path.blank? | |
puts " > \##{entry.id} #{uploader_name}" | |
image.recreate_versions! | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment