我正在尝试使用Delayed_job从我的rails 3.1应用程序异步发送邮件。
我按照github页面上的说明操作,但我的邮件没有发送(他们在我尝试使用这个宝石之前)。我看到它们被放在了作业表上,并且它们被消耗了,但是bundle exec rake jobs:work -v
任务没有给出任何输出。
这是我的控制器中的代码:
Notifier.delay.project_deleted(@project, current_user, u.email )
和我的邮件中的代码
def project_deleted(project, admin, destination)
@project = project
@admin = admin
mail to: destination
end
编辑:如果重要的话,我也会在Windows上执行此操作,并使用sqlite3数据库。
EDIT2:还有,奇怪的是:如果我添加了.deliver,我知道我不应该这样做,任务就会被执行并且邮件会被发送;尽管如此,控制器还是会回答:“未定义的方法传递”#
答案 0 :(得分:0)
我不确定Notifier.delay.project_deleted(@ project,current_user,u.email)是做什么的。
我将采取以下措施来确定问题。首先配置Hoptoad。然后=>
def project_deleted(project, admin, destination)
@project = project
@admin = admin
mail to: destination
rescue Exception => e
# send error to hoptoad
HoptoadNotifier.notify(
:error_class => "Unable to Send Mail",
:error_message => "Unable to send mail. ERROR: #{e.message}"
)
end