AnA*_*ice 19 ruby-on-rails heroku devise ruby-on-rails-3
我在Heroku上使用Devise有一个Rails 3应用程序.问题是我正在发送带有Sendgrid的电子邮件,而且电子邮件递送速度很慢,这会让应用程序挂起.所以我有兴趣使用delayed_job在后台排队电子邮件,因此我的应用程序响应用户.
Devise如何与delayed_job一起使用?设置Devise以使用delayed_job的任何方法?
Vee*_*Vee 24
来自Robert May:https://gist.github.com/659514
将其添加到config/initializers目录中的文件:
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
Run Code Online (Sandbox Code Playgroud)
我发现以上都不适合我.我正在使用Devise 2.0.4和Rails 3.2.2以及delayed_job_active_record 0.3.2
设计实际上谈论在代码中的注释中做这样的事情的方式是覆盖User类中的方法.因此,我这样解决了它,它完美地工作:
应用程序/模型/ User.rb
def send_on_create_confirmation_instructions
Devise::Mailer.delay.confirmation_instructions(self)
end
def send_reset_password_instructions
Devise::Mailer.delay.reset_password_instructions(self)
end
def send_unlock_instructions
Devise::Mailer.delay.unlock_instructions(self)
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5278 次 |
| 最近记录: |