default_url_options 的语法
syntax for default_url_options
我正在尝试发送 Devise 密码提醒电子邮件。当我单击提醒 link 时,日志文件包含此错误:
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主机也是邮件主机,他们有互联网域名'wombatdb.com'。如果我去生产 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 & unicorn 服务 97 次。
rails 4.2.7.1
ruby2.3.0
一切似乎都是正确的,你确定你已经在生产模式下启动了应用程序吗?尝试在 development.rb 上使用相同的配置并重试,关闭该选项。
我正在尝试发送 Devise 密码提醒电子邮件。当我单击提醒 link 时,日志文件包含此错误:
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主机也是邮件主机,他们有互联网域名'wombatdb.com'。如果我去生产 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 & unicorn 服务 97 次。
rails 4.2.7.1 ruby2.3.0
一切似乎都是正确的,你确定你已经在生产模式下启动了应用程序吗?尝试在 development.rb 上使用相同的配置并重试,关闭该选项。