Last active
August 29, 2015 14:05
-
-
Save aledalgrande/51a67892c6898c80b89c to your computer and use it in GitHub Desktop.
Sidekiq video upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gemfile | |
gem 'sidekiq' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# workers/transcode_worker.rb | |
require 'sidekiq' | |
class TranscodeWorker | |
include Sidekiq::Worker | |
def perform(id) | |
video = Video.find(id) | |
video.transcode if video | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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