Created
January 13, 2011 12:26
-
-
Save ljuti/777788 to your computer and use it in GitHub Desktop.
CarrierWave rake task to reprocess images for an object
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
# 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