邮件程序的 Rails 3 域
在我的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它必须在某处显式指定,因为否则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.