2013-06-12 3 views
1

MailForm (plataformatec)을 사용하는 연락처 페이지에 테이블이없는 모델이 있습니다. 사이드 킬 (Sidekiq)을 사용하여 메일을 백그라운드 프로세스로 보내고 싶었지만 주어진 모델의 ID에 의존합니다.tabless 모델이있는 Sidekiq

아무도 내가이 이메일을 백그라운드 프로세스로 보내는 방법을 알 수 있습니까? 당신은 Sidekiq에 모든 데이터를 전달해야 그것을 유지되지 않는 경우

이것은, 그럼 내 모델

class Contact < MailForm::Base 

    attribute :name,  :validate => true, :message => "aaa" 
    attribute :email,  :validate => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i 
    attribute :phone,  :validate => true 
    attribute :nickname, :captcha => true 

    def headers 
    { 
     :subject => "#{name}", 
     :to => "[email protected]", 
     :from => %("#{name}" <#{email}>) 
    } 
    end 
end 

답변

0

입니다. 예를 들어 해시로 전달할 수 있습니다. 컨트롤러, 모델에서

class ContactMailFormWorker 
    include Sidekiq::Worker 

    def perform(attributes) 
    contact = Contact.new attributes 
    contact.deliver 
    end 
end 

이든

ContactMailFormWorker.perform_async contact.attributes