通过Resque发送设计电子邮件 [英] Sending Devise emails through Resque

查看:108
本文介绍了通过Resque发送设计电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Resque发送Devise电子邮件。

I'm trying to send Devise emails through Resque.

定期的电子邮件通过Resque发送很好。而Devise电子邮件发送的很好,但不是通过Resque设计电子邮件。我得到找不到有效的映射,这意味着我的帮助覆盖没有被接收。

Regular emails are getting sent through Resque just fine. And Devise emails are sent just fine, but not Devise emails through Resque. I get "Could not find a valid mapping" which implies that my helper overrides aren't getting picked up.

我遵循这个http://shaker.4-dogs.biz/2011/08/06/使用-reque-to-send-mail-for-devise /

奇怪的是,要调试它,我正在使用Devise的本地副本并在Devise中的'initialize_from_record'中添加断点,当我仅仅使用Devise时,它会被击中。但是,当我发送Devise电子邮件通过resque断点不会被击中:

The odd thing is that to debug it I'm using a local copy of Devise and adding breakpoints in 'initialize_from_record' in Devise, which gets hit when I just use Devise alone. But when I send the Devise emails through resque the breakpoints don't get hit:

class ResqueMailer < Devise::Mailer
  include Resque::Mailer
end

config.mailer = "ResqueMailer"

然后resque显示一个打包的宝石路径,而不是我的本地来源,如:

And resque instead shows a packaged gem path and not my local source such as:

/Users/mm/.rvm/gems/ruby-1.9.2-p290@evergreen/gems/devise-1.4.9/lib/devise/mailers/helpers.rb:20:in `devise_mail'

任何想法为什么不使用我的本地宝石来源和/或如何让Resque发送我的Devise电子邮件? p>

Any idea why it's not using my local gem source AND/OR how to get Resque to send my Devise emails?

推荐答案

一个简单的方法是使用 devise-async gem。

An easy way is to use the devise-async gem.

将宝石添加到您的Gemfile中

Add the gem to your Gemfile

# Gemfile
gem "devise-async"

配置Devise以使用代理邮件程序。

Configure Devise to use the proxy mailer.

# config/initializers/devise.rb
config.mailer = "Devise::Async::Proxy"

[可选]最后告诉De viseAsync使用Resque来排列电子邮件。

[Optional] And finally tell DeviseAsync to use Resque to enqueue the emails.

# config/initializers/devise_async.rb
Devise::Async.backend = :resque

宝石还支持Sidekiq和Delayed :: Job。

The gem also supports Sidekiq and Delayed::Job.

这篇关于通过Resque发送设计电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆