Swathi K
Swathi K

Reputation: 276

Calling Sidekiq delay on class methods displays error

Calling delay on class method displays the following error:

    class Foo
      def self.bar
        puts "hello"
      end
    end



    Foo.delay.bar

Displays the following error

    {"retry"=>true, "queue"=>"default", "class"=>"Sidekiq::Extensions::DelayedClass",
    "args"=>["---\n- !ruby/class 'Foo'\n- :bar\n- []\n"], "jid"=>"0000000", 
    "enqueued_at"=>1391440659.34402, "error_message"=>"undefined class/module Foo", 
    "error_class"=>"ArgumentError", "failed_at"=>2014-02-03 15:17:39 UTC, 
    "retry_count"=>0}

Any idea why? Can we call delay on class methods?

Upvotes: 3

Views: 1835

Answers (3)

Steven Barragán
Steven Barragán

Reputation: 1254

I had the same problem and restart both redis and sidekiq didn't work.

I know it weird but it seems that sidekiq isn't loading everything well, anyway, the fix was to use a dedicated worker instead of a delayed class.

I hope it helps. https://github.com/mperham/sidekiq/wiki/Getting-Started

Upvotes: 1

Breno
Breno

Reputation: 6311

Restart your sidekiq and redis server. Worked for me.

Upvotes: 1

Logan Serman
Logan Serman

Reputation: 29880

It tells you why: undefined class/module Foo

Sidekiq doesn't see your Foo class. Make sure Sidekiq is loaded in an environment that can see Foo.

Upvotes: 0

Related Questions