Skip to content

Instantly share code, notes, and snippets.

@aledalgrande
Last active August 29, 2015 14:05
Show Gist options
  • Save aledalgrande/51a67892c6898c80b89c to your computer and use it in GitHub Desktop.
Save aledalgrande/51a67892c6898c80b89c to your computer and use it in GitHub Desktop.
Sidekiq video upload
# Gemfile
gem 'sidekiq'
# workers/transcode_worker.rb
require 'sidekiq'
class TranscodeWorker
include Sidekiq::Worker
def perform(id)
video = Video.find(id)
video.transcode if video
end
end
# app/models/video.rb
class Video < ActiveRecord::Base
after_create enqueue_transcoding_job
def enqueue_transcoding_job
TranscodeWorker.perform_async(id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment