diff --git a/lib/tasks/paperclip.rake b/lib/tasks/paperclip.rake index 53d6af864..7d2df8af5 100644 --- a/lib/tasks/paperclip.rake +++ b/lib/tasks/paperclip.rake @@ -22,10 +22,28 @@ namespace :paperclip do end end - desc "List all paperclip files" + desc 'List all paperclip files' task files: :environment do print_model_files Asset, :file print_model_files User, :avatar end + desc 'Reprocess the Assets attachents styles' + task reprocess: :environment do + error = false + Asset.find_each(batch_size: 100) do |asset| + next unless asset.is_image? + begin + asset.file.reprocess! :medium, :large + rescue + error = true + $stderr.puts "exception while processing #{asset.file_file_name} " \ + "ID: #{asset.id}:" + end + end + unless error + $stderr.puts 'All gone well! ' \ + 'You can grab a beer now and enjoy the evening.' + end + end end