Rails + Devise + delayed_job?

后端 未结 9 2085
长情又很酷
长情又很酷 2020-12-24 07:38

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 dela

9条回答
  •  醉话见心
    2020-12-24 08:29

    I'm not sure Devise provides an easy way to do backgrounding of email delivery. However there are ways to be able to do that with DelayedJoy. DelyedJob provides a function "handle_asynchronously" which if injected into the DeviseMailer can ensure that deliveries happen in the background.

    Try this in your config/application.rb

    config.after_initialize do 
      ::DeviseMailer.handle_asynchronously :deliver_confirmation_instructions 
      # or
      ::DeviseMailer.handle_asynchronously :deliver!
    end
    

    You will need to experiment with that. You could also try to inherit the DeviseMailer and set it to deliver asynchronously in an initializer in config/initializer/devise_mailer_setup.rb or something to that effect.

提交回复
热议问题