Migration to Shrine attachment handling
This commit is contained in:
parent
2d53397dda
commit
c4f5741b0c
13 changed files with 175 additions and 181 deletions
27
lib/tasks/paperclip_to_shrine.rake
Normal file
27
lib/tasks/paperclip_to_shrine.rake
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#require 'paperclip_shrine_synchronization'
|
||||
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue