我正在尝试将Devise密码提醒电子邮件发送出去。单击提醒链接时,日志文件包含以下错误:
I, [2017-04-22T21:11:37.394060 #1265] INFO -- : Rendered devise/mailer/reset_password_instructions.html.erb (3.5ms)
D, [2017-04-22T21:11:37.394372 #1265] DEBUG -- :
Devise::Mailer#reset_password_instructions: processed outbound mail in 6.9ms
I, [2017-04-22T21:11:37.394835 #1265] INFO -- : Completed 500 Internal Server Error in 33ms (ActiveRecord: 4.5ms)
F, [2017-04-22T21:11:37.398625 #1265] FATAL -- :
ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
2:
3: <p>Someone has requested a link to change your password. You can do this through the link below.</p>
4:
5: <p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
6:
7: <p>If you didn't request this, please ignore this email.</p>
8: <p>Your password won't change until you access the link above and create a new one.</p>
app/views/devise/mailer/reset_password_instructions.html.erb:5:in `_app_views_devise_mailer_reset_password_instructions_html_erb___1026568370915801248_70174322925120'
我认为我只是在设置配置时遇到语法问题。查看config/environments/production.rb
:
Rails.application.configure do
...
config.action_mailer.default_url_options = {host: 'wombatdb.com'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "wombatdb.com",
:domain => "wombatdb.com",
:enable_starttls_auto => false,
:openssl_verify_mode => OpenSSL::SSL::VERIFY_NONE
}
...
end
rails主机也是邮件主机,他们有互联网域名&#39; wombatdb.com&#39;。如果我去生产rails控制台,我可以像这样读取配置:
rails@wombatdb:~/wombat$ bin/rails c production
Loading production environment (Rails 4.2.7.1)
irb(main):001:0> ActionMailer::Base.default_url_options
=> {:host=>"wombatdb.com"}
关于什么可能出错的任何想法?我重启了nginx&amp;独角兽服务97次。
rails 4.2.7.1 ruby 2.3.0
答案 0 :(得分:1)
一切似乎都是正确的,你确定你已经在生产模式下启动了应用程序吗?尝试在development.rb上使用相同的配置,然后再试一次,以解除该选项。