I'm adding Sidekiq into my Rails 4 app (not doing anything with perform_async
), and when I delay
a job, in my case mailing something, Rails complains that there is no method named delay
. This is what I'm calling:
MyMailer.delay.signup_notification(@user.id, @user.email)
I've added the gem and saw that bundle install
listed the gem (using sidekiq 2.11.0), I'm developing locally and running bundle exec sidekiq
along with a Redis server locally on 127.0.0.1:6379 (default port 6379).
Why is Sidekiq's method definition not found? A weird thing also is that RubyMine can jump to the definition, but when I run Rails, it gives the error that delay
is not found. I see in Sidekiq's definition that it's supposed to extend delay
to every class.
Try running gem "sidekiq"
in console. If it returns true, try running this snippet:
class TestMailer < ActionMailer::Base; def x; end; end; TestMailer.delay
You should get some output back from Redis.
If the first command fails, you're not including sidekiq
properly in your Gemfile
. If the second command fails, you're doing something weird in your MyMailer
class.
Remember, if you're running Rails console in the development
environment (if you don't know, you probably are, but you can check with Rails.env
) you'll need to let development
have access to the gem in the Gemfile
.
Just had something similar... but triggered by a Sidekiq update.
https://github.com/mperham/sidekiq/wiki/Delayed-extensions says,
They are disabled by default in Sidekiq 5+. Use Sidekiq::Extensions.enable_delay! to turn them on.
Add Sidekiq::Extensions.enable_delay! to the initializer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.