mail_form gem 与 sidekiq 工作者

mail_form gem with sidekiq worker

如何让mail_formgem与sidekiq worker一起工作? https://github.com/plataformatec/mail_form

我可能做错了什么,但这段代码抛出 NoMethodError

-contact_worker.rb

class ContactWorker
  include Sidekiq::Worker

  def perform(c)
    c.deliver
  end
end

-contacts_controller.rb

  def create
    @contact = Contact.new(contact_params)
    @contact.request = request
    ContactWorker.perform_async(@contact)    
    redirect_to root_path
  end

-

2015-07-26T19:12:46.746Z 5785 TID-oxh33etuc ContactWorker JID-014a6a9987980a03f49c355c INFO: start
2015-07-26T19:12:46.747Z 5785 TID-oxh33etuc ContactWorker JID-014a6a9987980a03f49c355c INFO: fail: 0.001 sec
2015-07-26T19:12:46.749Z 5785 TID-oxh33etuc WARN: {"class"=>"ContactWorker", "args"=>["#<Contact:0x007fcf4ef713e8>"], "retry"=>true, "queue"=>"default", "jid"=>"014a6a9987980a03f49c355c", "created_at"=>1437937936.264524, "enqueued_at"=>1437937966.741929, "error_message"=>"undefined method `deliver' for \"#<Contact:0x007fcf4ef713e8>\":String", "error_class"=>"NoMethodError", "failed_at"=>1437937936.284221, "retry_count"=>1, "retried_at"=>1437937966.747125}
2015-07-26T19:12:46.749Z 5785 TID-oxh33etuc WARN: NoMethodError: undefined method `deliver' for "#<Contact:0x007fcf4ef713e8>":String
2015-07-26T19:12:46.749Z 5785 TID-oxh33etuc WARN: /Users/______/Desktop/______/app/workers/contact_worker.rb:5:in `perform'

.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/processor.rb:75:in `execute_job'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:127:in `block in invoke'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/middleware/server/logging.rb:15:in `block in call'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/logging.rb:30:in `with_context'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/middleware/server/logging.rb:11:in `call'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:132:in `call'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/middleware/chain.rb:132:in `invoke'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/processor.rb:51:in `block in process'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/processor.rb:98:in `stats'
.rvm/gems/ruby-2.2.2/gems/sidekiq-3.4.2/lib/sidekiq/processor.rb:50:in `process'
.rvm/gems/ruby-2.2.2/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `public_send'
.rvm/gems/ruby-2.2.2/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `dispatch'
.rvm/gems/ruby-2.2.2/gems/celluloid-0.16.0/lib/celluloid/calls.rb:122:in `dispatch'
.rvm/gems/ruby-2.2.2/gems/celluloid-0.16.0/lib/celluloid/cell.rb:60:in `block in invoke'
.rvm/gems/ruby-2.2.2/gems/celluloid-0.16.0/lib/celluloid/cell.rb:71:in `block in task'
.rvm/gems/ruby-2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:357:in `block in task'
.rvm/gems/ruby-2.2.2/gems/celluloid-0.16.0/lib/celluloid/tasks.rb:57:in `block in initialize'
.rvm/gems/ruby-2.2.2/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15:in `block in create'

worker 和 mailer 应该是两个独立的类。