I am trying to use delayed_job to run some code in background and give the user some response immediately.
class Batch
def self.taskmy
# some very long task
end
def taskmy
self.taskmy
end
handle_asynchronously :taskmy
end
My controller action look like below
def send_command
count = 0
count2 = 0
Batch.delay.taskmy
puts count
puts count2
end
But i get an error
ActiveRecord::ConnectionNotEstablished: No connection pool with id primary > > found
I started the job with
rake jobs:work
I was using the active record gem with mongodb. i included following in my gemfile and restarted the job. gem 'delayed_job_mongoid'