namespace :debshots do desc "Convert images from Paperclip (deprecated) to Shrine" task paperclip_to_shrine: :environment do Screenshot.find_each do |screenshot| puts "Screenshot… #{screenshot.id}" path = screenshot.image.path puts "Image path… #{path}" # Skip run if there is a Shrine attachment already (idempotency) next if screenshot.simage # Upload file as Shrine screenshot.simage = File.open(path) puts "Creating derivatives…" screenshot.simage_derivatives! screenshot.save! puts "------------" end end end