Topic: Undefined method 'delay' when using delayed_job

I am trying to use the delayed_job gem using the .delay method but the page I tried to load always come back with undefined method 'delay' for #<Device: ....>

I followed the steps in http://rubydoc.info/gems/delayed_job/2.1.4/frames to install the gem and then created the database table.

I then used the example from the same site:

class Device
  def deliver
     puts "About to do processing ..."
     sleep 30
     puts "Done!"
  end
end


class CustomersController < ApplicationController
...
  def edit
    @customer = Customer.find(params[:id])
    device = Device.new
    device.delay.deliver
  end

  ...
end

When I load the URL http://localhost:3000/customers/1/edit, I get the

NoMethodError in CustomersController@edit.

undefined method 'delay' ... etc

I am using the following versions, as reported by

gem list

delayed_job (2.1.4)
rails (3.0.10, 3.0.9)
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux]

Can someone suggests how I can work out where the problem may be?

Many thanks!

Last edited by danielwu (2011-08-23 03:14:46)