4

https://github.com/mperham/sidekiq/wiki/Delayed-Extensionsに従って、sidekiq 遅延拡張機能の指示に従いました。

sidekiq バージョン 2.14.1 の使用

class ContactController < ApplicationController
  def create
    contact = params[:contact]
    ContactMailer.delay.email_support(contact[:name], contact[:email], contact[:phone], contact[:category], contact[:details])
    redirect_to contact_path, notice: t("contact.email_support.sent_confirmation_flash")
  end
end

#/app/mailers/contact_mailer.rb
class ContactMailer < ActionMailer::Base
  default from: "test@test.com"

  def email_support(name, email, phone, category, details)
    @name = name
    @email = email
    @phone = phone
    @category = category
    @details = details
    @title = "#{t('contact.email_support.title')} - #{@category}"
    mail(:to => "support@test.com", subject: @title)
  end
end

何らかの理由で、未定義のクラス/モジュール エラーが発生します。

2013-09-13T16:39:57Z 73620 TID-ov93oo7a8 WARN: undefined class/module ContactMailer
2013-09-13T16:39:57Z 73620 TID-ov93oo7a8 WARN: /Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:334:in `path2class'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:334:in `resolve_class'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:71:in `deserialize'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:104:in `visit_Psych_Nodes_Scalar'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:259:in `block in register_empty'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:259:in `each'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:259:in `register_empty'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:122:in `visit_Psych_Nodes_Sequence'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:240:in `visit_Psych_Nodes_Document'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych/nodes/node.rb:35:in `to_ruby'
/Users/sunnyto/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/psych.rb:130:in `load'

私の sidekiq キューは次のようになります。

キュー: デフォルト

ワーカー: Sidekiq::Extensions::DelayedMailer

引数: "---\n- !ruby/class 'ContactMailer'\n- :email_support\n- - afadf\n - ''\n - ''\n - ''\n - afdadf...

4

1 に答える 1

1

sidekiq mailer gem https://github.com/andersondias/sidekiq_mailerを試してみてください。

于 2014-10-27T18:53:45.013 に答える