【发布时间】: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