使用sidekiq时,Rails Action Mailer中的动态域名 [英] Dynamic domain name in Rails action mailer while using sidekiq
问题描述
在我的要求中,单个项目有不同的域名。我想使用用户请求重置密码的域名发送重置密码链接。为此,我在application_controller.rb中完成了以下操作
In my requirement ,there are different domain names for single project.I would like to send reset password link with a domain name where the user requested for the reset password.For that I have done the follows in application_controller.rb and it works well.
before_filter :set_mailer_host
def set_mailer_host
ActionMailer::Base.default_url_options[:host] = request.host_with_port
$url_host = request.host_with_port
end
稍后,我已经使用sidekiq来延迟发送邮件,并在整个应用程序上进行了如下更新
Later,I have used sidekiq for delayed mailer and updated like follows on entire application
Notifier.delay.password_reset(user.id)
由于已为邮件程序配置了sidekiq,因此它仅使用配置中提供的默认域名,而未使用从application_controller.rb上的请求提供的动态域名。
As the mailer was configured with sidekiq it was using default domain name provided in configuration only and it was not using the dynamic domain name provided from request on application_controller.rb
任何建议在sidekiq运行的邮件上获取动态域名都会
Any suggestion to get the dynamic domain on mailers running by sidekiq would be greatly appreciated.
Rails-3.2.8
Ruby-1.9.3
sidekiq-2.13.1
Rails - 3.2.8 Ruby - 1.9.3 sidekiq - 2.13.1
谢谢!
推荐答案
其中一种选择是将每个用户与一个域关联,在sidekiq发送电子邮件时使用此信息。
One of the options would be to associate each user with a domain and use this information when sending the email in sidekiq.
这篇关于使用sidekiq时,Rails Action Mailer中的动态域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!