The given task does not have to be an ActiveRecord model, you can add functionality to the plain old Ruby class, see https://github.com/collectiveidea/delayed_job#custom-jobs
You probably do not want the controller action to be processed asynchronously, as this would add unnecessary delay to the HTTP request. My advice would be to set the task in the dispatcher like this:
class CollectionsController < ApplicationController def add Delayed::Job.enqueue CollectionBuilderJob.new(@current_user.session_info) end end class CollectionBuilderJob < Struct.new(:session_info) def perform
This approach allows you to isolate pending work
source share