Rails + Devise + delay_job? [英] Rails + Devise + delayed_job?

查看:23
本文介绍了Rails + Devise + delay_job?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Heroku 上使用 Devise 的 Rails 3 应用程序.问题是我正在使用 Sendgrid 发送电子邮件,但电子邮件发送速度很慢,这使应用程序挂起.所以我有兴趣使用 delay_job 在后台将电子邮件发送排队,以便我的应用能够响应用户.

I have a Rails 3 App using Devise on Heroku. Problem is I'm sending emails with Sendgrid and email delivery is slow, it makes the app hang. So I'm interested in using delayed_job to queue the email delivery in the background so my app is responsive to the user.

Devise 如何与delayed_job 一起使用?有什么方法可以设置 Devise 使用 delay_job?

How can Devise be used with delayed_job? Any way to setup Devise to use delayed_job?

推荐答案

来自 Robert May:https://gist.github.com/659514

From Robert May: https://gist.github.com/659514

将其添加到 config/initializers 目录中的文件中:

Add this to a file in config/initializers directory:

module Devise
  module Models
    module Confirmable
      handle_asynchronously :send_confirmation_instructions
    end

    module Recoverable
      handle_asynchronously :send_reset_password_instructions
    end

    module Lockable
      handle_asynchronously :send_unlock_instructions
    end
  end
end

这篇关于Rails + Devise + delay_job?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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