Skip to content

Instantly share code, notes, and snippets.

@simoleone
Created March 28, 2019 12:54
Show Gist options
  • Save simoleone/adf09f30176b478f9cf2a933ba9f697a to your computer and use it in GitHub Desktop.
Save simoleone/adf09f30176b478f9cf2a933ba9f697a to your computer and use it in GitHub Desktop.
Async image processing in Shrine
Shrine.plugin :backgrounding
Shrine::Attacher.promote { |data| ShrinePromoteWorker.perform_async(data) }
Shrine::Attacher.delete { |data| ShrineDeleteWorker.perform_async(data) }
class ShrineDeleteWorker < ApplicationWorker
def perform(data)
Shrine::Attacher.delete(data)
end
end
class ShrinePromoteWorker < ApplicationWorker
def perform(data)
Shrine::Attacher.promote(data)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment