【问题标题】:Missing host to link to Rails heroku production缺少链接到 Rails heroku 生产的主机
【发布时间】:2017-01-07 22:44:55
【问题描述】:

我有一个正在尝试投入生产的应用程序。当用户注册时,他们有一封应该发送到他们的电子邮件帐户的激活电子邮件,但我因以下错误而停止:

ActionView::Template::Error(Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true)

这个错误的问题是我在我的文件中正确设置了所有内容。例如,我的环境文件夹中的 production.rb 文件如下所示:

  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.default_url_options = { :host => 'secret-everglades-54128.heroku.com'}
  ActionMailer::Base.smtp_settings = {
    :address        => 'smtp.sendgrid.net',
    :port           => '587',
    :authentication => :plain,
    :user_name      => ENV['SENDGRID_USERNAME'],
    :password       => ENV['SENDGRID_PASSWORD'],
    :domain         => 'heroku.com',
    :enable_starttls_auto => true
  }

我的 enviorments.rb 文件如下所示:

# Load the Rails application.
require_relative 'application'

# Initialize the Rails application.
Rails.application.initialize!

config.action_mailer.default_url_options = { :host => 'secret-everglades-54128.heroku.com'}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }

这对我来说没有任何意义,如果有人能对这个问题有所了解,我会非常满意。

【问题讨论】:

    标签: ruby-on-rails heroku sendgrid


    【解决方案1】:

    问题是我在运行命令时仍然出现错误

     git push heroku master
    

    问题是我在不需要的实际 environment.rb 文件中设置了我的主机,所以我删除了它,一旦我这样做了,我就能让一切正常工作。

    【讨论】:

      猜你喜欢
      • 2019-07-30
      • 1970-01-01
      • 2017-11-08
      • 1970-01-01
      • 1970-01-01
      • 2013-11-30
      • 2014-07-06
      • 2015-07-12
      • 1970-01-01
      相关资源
      最近更新 更多