首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ActionView::Template::Error:缺少要链接到的主机!请提供:host参数、设置default_url_options[:host]或将:only_path设置为true

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

Stack Overflow用户
提问于 2014-03-09 22:18:38
回答 2查看 20.9K关注 0票数 28

我的ruby on rails动作邮件程序在开发环境中运行很好,但是在生产环境中,它保持抛出:

代码语言:javascript
复制
ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true

我的开发配置是

代码语言:javascript
复制
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' }

我的生产配置是

代码语言:javascript
复制
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' }

我的其他环境是:

代码语言:javascript
复制
ruby 2.1.1
rails 4.0.3
sidekiq
devise
devise-async

我试过:

  1. 在初始化程序文件中添加以下内容 ActionMailer::Base.default_url_options:host = "example.com“

  1. 这个答案here

这两种都不管用。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 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

代码语言:javascript
复制
# Default Mailer Host
  Rails.application.routes.default_url_options[:host] = 'domain.example'
票数 83
EN

Stack Overflow用户

发布于 2014-07-07 17:55:59

尝试重新启动服务器。即使在Rails 4.1中,如果没有重新启动,配置也不会重新分析。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22288951

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档