# lib/worker.rb
require 'sidekiq'
require 'model' # lib/model.rb
class AwesomeWorker
include Sidekiq::Worker
def perform
RandomNumberModel.create! { random_number: Random.new.rand(1..100) }
end
end
uninitialized constant AwesomeWorker::RandomNumberModel
class AwesomeWorker
def perform model_id
model = ObjectSpace._id2ref(model_id.to_i)
model.update_attributes { random_number: Random.new.rand(1..100) }
end
end
AwesomeWorker.perform_async AwesomeModel.new.object_id
class AwesomeWorker
def perform
::AwesomeModel.create! { random_number: Random.new.rand(1..100) }
end
end