처음에는 메소드 email_coupon_sent를 사용하여 CastingMailer 클래스를 만들었고 메일러에 필요한 모든 클래스로 CouponMailer 클래스를 만들고이 클래스에 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를 계속 찾고있는 이유는 무엇입니까?레일스 5 sidekiq 작업이 이전 클래스를 계속 참조합니다.
코드
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
보기/0 coupon_mailer
내 CastingMailer에서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'
현재 email_coupon_sent 방법을 사전에
감사 없다.
생산 환경입니까, 개발 환경입니까? 변경 후 사이드 키를 다시 시작 했습니까? –