Skip to content

Instantly share code, notes, and snippets.

@czj
Created August 24, 2016 15:24
Show Gist options
  • Save czj/511ed37657506f99be1a24534b838ab1 to your computer and use it in GitHub Desktop.
Save czj/511ed37657506f99be1a24534b838ab1 to your computer and use it in GitHub Desktop.
Re-generate Shrine.rb attached file versions for a Rails model
# Run in smalls batches, for memory usage and to re-start on failure / SSH connexion lost
600.times { |i|
n = i * 100
puts "Processing #{n} ..."
Imaj.where(id: (n + 1)..(n + 100)).each { |e|
e.update!(picture: e.picture[:original]) if e.picture_attacher.stored?
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment