【发布时间】:2014-04-12 21:27:38
【问题描述】:
我的 ruby on rails action mailer 在开发环境中运行良好,但在生产环境中,它一直抛出:
ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
我的开发配置是
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:port => xxx,
:address => 'smtp.example.org',
:user_name => 'xxx@example.com',
:password => 'xxxxxxxx',
:domain => 'xxxxxx.com',
:authentication => :plain,
}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
我的生产配置是
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:port => 587,
:address => 'smtp.example.org',
:user_name => 'xxx@example.com',
:password => 'xxxxxx',
:domain => 'example.com',
:authentication => :plain,
}
config.action_mailer.default_url_options = { :host => 'example.com' }
我的其他环境是:
ruby 2.1.1
rails 4.0.3
sidekiq
devise
devise-async
我试过了:
-
在初始化文件中添加以下内容
ActionMailer::Base.default_url_options[:host] = "example.com" 这个答案here
它们都不起作用。
【问题讨论】:
-
这很奇怪。我刚刚遇到了同样的错误,将 config.action_mailer.default_url_options = { :host => "example.com" } 添加到我的 application.rb 解决了这个问题......你确定你的配置被正确选择了吗?
标签: ruby-on-rails-4 devise actionmailer production