邮件程序的 Rails 3 域

发布于 2024-10-09 20:09:49 字数 189 浏览 0 评论 0原文

在我的 config/application.rb 文件中,有一行:

 config.action_mailer.default_url_options = { :host => 'example.com' }

如何从托管我的 Rails 应用程序的域自动配置默认 url 选项的主机属性?

in my config/application.rb file I have a line:

 config.action_mailer.default_url_options = { :host => 'example.com' }

How can I configure the host attribute for default url options automaticaly from the domain, where my Rails app is hosted ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽手叙旧 2024-10-16 20:09:49

它必须在某处显式指定,因为否则rails如何知道域是什么?..通过浏览器(或curl或其他)的请求将有一个rails知道的主机,但是如果加载rails控制台,什么域名是?

如果您使用的是 capistrano 之类的东西,您可以编写一个任务来创建一个初始化程序,该初始化程序根据您在部署配方中设置的主机设置邮件程序 URL。

It has to be explicitly specified somewhere because how else would rails know what the domain is?.. A request through the browser (or curl, or whatever) will have a host which rails knows about, but if you load up rails console, what would the domain be?

If you're using something like capistrano, you could write a task to create an initializer which sets the mailer url depending on the host(s) you've set in your deploy recipe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文