我的ruby on rails动作邮件程序在开发环境中运行很好,但是在生产环境中,它保持抛出:
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.example',
: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我试过:
这两种都不管用。
发布于 2014-07-17 06:18:27
最后,我向每个环境文件添加了具有正确值的以下内容:
test.rb / development.rb / production.rb
设计3.2.x - 4.x.x
Rails 4.1.x && Rails 4.2.x && Rails 5.x.x
多亏了maudulus
# Default Mailer Host
Rails.application.routes.default_url_options[:host] = 'domain.example'发布于 2014-07-07 17:55:59
尝试重新启动服务器。即使在Rails 4.1中,如果没有重新启动,配置也不会重新分析。
https://stackoverflow.com/questions/22288951
复制相似问题