小编Chu*_*Zhu的帖子

ActionView :: Template ::错误:缺少链接到的主机!请提供:host参数,设置default_url_options [:host],或将:only_path设置为true

我的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
Run Code Online (Sandbox Code Playgroud)

我的开发配置是

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' }
Run Code Online (Sandbox Code Playgroud)

我的生产配置是

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,
} …
Run Code Online (Sandbox Code Playgroud)

production actionmailer devise ruby-on-rails-4

26
推荐指数
1
解决办法
2万
查看次数