多的不说直接上代码
class UserMailer < Devise::Mailer
# customize mail format
def user_feedback(opts={})
@v = "Hello"
@opts = opts
mail(:to => "[email protected]", :bcc => ["[email protected]"], :subject => "Test")
end
handle_asynchronously :user_feedback
end
class MailsController < ApplicationController
def feedback
options[:feedback_time] = Time.now.strftime("%Y%m%d %H:%M:%S")
UserMailer.user_feedback(options).deliver
end
end
启动 worker
rake jobs:workoff
log
[Worker(host:localhost.localdomain pid:2899)] Starting job worker
[Worker(host:localhost.localdomain pid:2899)] Job Delayed::PerformableMethod (id=18) RUNNING
[Worker(host:localhost.localdomain pid:2899)] No more jobs available. Exiting
不太懂了,顺便提一下 rails 版本是 4.0.4