lundi 4 novembre 2019

ActionView Template Error: Missing host to link to settings with no effect

I am updating an old rails 3 application to rails 4. When I run my tests with test unit I am getting the following error in my actionmailer:

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

After some research I found that it requires the options

# in: environment.rb 
# Set the default host and port to be the same as Action Mailer.
Rails.application.default_url_options = Rails.application.config.action_mailer.default_url_options

# and in each environment an entry like this: 
# environments/test.rb 
config.action_mailer.default_url_options = { host: 'localhost', port: '3000' }

While I can confirm these settings are set in the rails console. The error does not go away.

2.0.0-p648 :002 > Rails.application.default_url_options
 => {:host=>"localhost", :port=>"3000"} 
2.0.0-p648 :003 > Rails.application.config.action_mailer.default_url_options
 => {:host=>"localhost", :port=>"3000"} 

Aucun commentaire:

Enregistrer un commentaire