gpt4 book ai didi

ruby-on-rails-4 - ActionView::Template::Error: 缺少要链接的主机!请提供 :host 参数,设置 default_url_options[:host],或设置 :only_path 为 true

转载 作者:行者123 更新时间:2023-12-03 10:18:35 25 4
gpt4 key购买 nike

我的 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

  • 它们都不起作用。

    最佳答案

    最后,我在每个环境文件中添加了以下具有正确值的内容:

    test.rb/development.rb/production.rb

    设计 3.2.x - 4.x.x

    Rails 4.1.x && Rails 4.2.x && 导轨 5.x.x

    感谢 maudulus

    # Default Mailer Host
    Rails.application.routes.default_url_options[:host] = 'domain.com'

    关于ruby-on-rails-4 - ActionView::Template::Error: 缺少要链接的主机!请提供 :host 参数,设置 default_url_options[:host],或设置 :only_path 为 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22288951/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com