encoded_file = VideoEncoder.new.encode(video, size) FileUploader.new.upload(encoded_file, to: key) end end class VideosController < ApplicationController def create @video = Video.create!(video_params) ["1920x1080", "1270x720", "960x540"].each do |size| VideoEncodeWorker.perform_async(@video.id, size) end { status: "OK" } end end