Search code examples
ruby-on-railsrubyruby-on-rails-3delayed-job

delayed_jobs not creating rows in delayed_jobs table


In may rails application i wanted to use delayed job. SO i installed delayed jobs as follows.

in gemfile

 gem 'delayed_job_active_record', '0.4.3'

then in console

 rails generate delayed_job:active_record

 rake db:create

It had created delayed_jobs table in database.

And i started

 rake jobs:work

Then i added the following code in controller:

 Task.handle_asynchronously :in_the_future, :run_at => Proc.new { 5.minutes.from_now }

here Task is the model name.

And in the model task.rb i wrote

 def in_the_future
   self.update_attiributes(:status=> "updated")
 end

After running controller method it's not creating any record in the delayed_jobs table. Please correct me if i am doing anything wrong.


Solution

  • Can You change the controller code to

    Task.delay(:run_at => Proc.new { 5.minutes.from_now }).in_the_future