使用sidekiq时,Rails Action Mailer中的动态域名 [英] Dynamic domain name in Rails action mailer while using sidekiq

查看:101
本文介绍了使用sidekiq时,Rails Action Mailer中的动态域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的要求中,单个项目有不同的域名。我想使用用户请求重置密码的域名发送重置密码链接。为此,我在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屋!

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