簡體   English   中英

Rails 5 sidekiq工作繼續引用舊類

[英]rails 5 sidekiq jobs keep referencing old class

最初,我有一個CastingMailer類,其方法為email_coupon_sent,創建了類CouponMailer,其中包含了mailer所需的所有內容,然后將方法email_coupon_sent放入該類中,在我的工作中,我稱為CouponMailer.email_coupon_sent,sidekiq在日志2017-02中告訴了我-14T15:42:05.066Z 7344 TID-ynsk0警告:NoMethodError:CastingMailer:Class的未定義方法`email_coupon_sent',為什么sidekiq繼續在CastingMailer類中尋找email_coupon_sent。

admin_controller.rb

@coupon.give!
CouponSentJob.perform_later(@user.profileable, @coupon)

coupon_sent_job.rb

def perform(profile, coupon)
  # Send coupon to user
  Notification.notify_coupon_sent(profile, coupon)
  CouponMailer.email_coupon_sent(profile, coupon).deliver_now
end

coupon_mailer.rb

def email_coupon_sent(profile, coupon)
  @profile = profile
  @coupon = coupon
  mail(to: @profile.user.email, subject: I18n.t('views.mailers.coupon.coupon_sent.subject'))
end

意見/ coupon_mailer

email_coupon_sent.html.erb
email_coupon_sent.text.erb

sidekiq.log

2017-02-14T15:42:04.980Z 7344 TID-ynsk0 CouponSentJob JID-0b611e12bcd38bd3fc87b86c INFO: start
2017-02-14T15:42:05.065Z 7344 TID-ynsk0 CouponSentJob JID-0b611e12bcd38bd3fc87b86c INFO: fail: 0.085 sec
2017-02-14T15:42:05.066Z 7344 TID-ynsk0 WARN: {"context":"Job raised exception","job":       {"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","wrapped":"CouponSentJob","queue":"default","args":   [{"job_class":"CouponSentJob","job_id":"d6f830a6-db9f-4af8-bb0c-83580536a8db","queue_name":"default","priority":null,"arguments":  [{"_aj_globalid":"gid://cubamodela/ProfileModel/4"},{"_aj_globalid":"gid://cubamodela/Coupon/6"}],"locale":"en"}  ],"retry":true,"jid":"0b611e12bcd38bd3fc87b86c","created_at":1487086924.9707098,"enqueued_at":1487086924.9742587,"error_message":"undefined   method `email_coupon_sent' for     CastingMailer:Class","error_class":"NoMethodError","failed_at":1487086925.0644813,"retry_count":0},"jobstr":"{\"class\":  \"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper\",\"wrapped\":\"CouponSentJob\",\"queue\":\"default\",\"args\":[{\"job_class\":  \"CouponSentJob\",\"job_id\":\"d6f830a6-db9f-4af8-bb0c-83580536a8db\",\"queue_name\":\"default\",\"priority\":null,\"arguments\":  [{\"_aj_globalid\":\"gid://cubamodela/ProfileModel/4\"},{\"_aj_globalid\":\"gid://cubamodela/Coupon/6\"}],\"locale\":\"en\"}],\"retry\":true,  \"jid\":\"0b611e12bcd38bd3fc87b86c\",\"created_at\":1487086924.9707098,\"enqueued_at\":1487086924.9742587}"}
2017-02-14T15:42:05.066Z 7344 TID-ynsk0 WARN: NoMethodError: undefined method `email_coupon_sent' for CastingMailer:Class
2017-02-14T15:42:05.066Z 7344 TID-ynsk0 WARN: /home/deployer/.rvm/gems/ruby-2.3.1/gems/actionmailer-5.0.1/lib/action_mailer/base.rb:565:in   `method_missing'
/home/deployer/cubamodela/app/jobs/coupon_sent_job.rb:6:in `perform'
/home/deployer/.rvm/gems/ruby-2.3.1/gems/activejob-5.0.1/lib/active_job/execution.rb:34:in `block in perform_now'
/home/deployer/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.1/lib/active_support/callbacks.rb:126:in `call'

在我的CastingMailer中,目前沒有email_coupon_sent方法

提前致謝。

作業將保存需要調用的類和方法名稱。 如果有些作業仍在Redis中引用它,則不能重命名。 您必須確保不再有引用該名稱的作業。 最簡單的方法是刷新整個Redis數據庫,但這會清除所有內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM