设计和邮件程序 - 如何获取当前 URL
使用 Devise 发送电子邮件(例如“重置密码说明”)时,我需要知道当前的域 URL,并将该值设置到邮件程序的模板中。
request.url 对我不起作用。
假设可以从多个 URL 访问此 Rails 应用程序。
有什么想法吗?
When sending emails (for example for 'Reset password instructions') using Devise, i need to know current domain URL, and set that value into mailer's template.
request.url doesn't work for me.
Assuming, this Rails application is accessibly from multiple URLs.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请求对象在邮件程序中不可用。您需要在环境配置文件中设置主机,如下所示:
ActionMailer::Base.default_url_options[:host] = 'myhost.com'
Request object is not available in the mailers. You will need to set up the host in the environment configuration file with something like:
ActionMailer::Base.default_url_options[:host] = 'myhost.com'