Dave Morse
Dave Morse

Reputation: 757

syntax for default_url_options

I am trying to get Devise password reminder emails to go out. When I click the reminder link, the log file contains this error:

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'

I think I am just having a syntax problem with setting configuration. Check out 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

The rails host is also the mailer host, and they have internet domain name 'wombatdb.com'. If I go to the production rails console, I can read the config out like so:

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"}

Any ideas on what could be wrong? I restarted nginx & unicorn services 97 times.

rails 4.2.7.1 ruby 2.3.0

Upvotes: 0

Views: 677

Answers (1)

xploshioOn
xploshioOn

Reputation: 4115

everything seems to be correct, are you sure that you have started the app on production mode? try using the same config on development.rb and try again, to dismiss that option.

Upvotes: 1

Related Questions