1

Using named routes in any of my application's mailers is raising this error:

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

This isn't happening all the time and I can't reproduce locally in either development or production mode.

If I open a console in production, I can confirm that the default host is configured:

ActionMailer::Base.default_url_options
 => {:host=>"thehost.com"} 
Rails.application.config.action_mailer.default_url_options
 => {:host=>"thehost.com"} 
Spree::Core::Engine.config.action_mailer.default_url_options
 => {:host=>"thehost.com"} 

All the named routes are being called through Spree's routing proxy:

<%= spree.my_route_url %>

I have the following in config/environments/production.rb

config.action_mailer.default_url_options = { :host => "thehost.com" }

This may be redundant since Spree also sets it from the :site_url preference (which I have configured correctly)

ActionMailer::Base.default_url_options[:host] = Spree::Config[:site_url]

(from mail_settings.rb)

Spree is version 1-0-stable Rails 3.1.3 Ruby 1.9.3

DavidNorth
  • 450
  • 3
  • 14
  • I was able to confirm that when this error happens, default_url_options is: {"host"=>""}. Seems that restarting the processes, or in a console that value gets set correctly. – DavidNorth Aug 16 '12 at 15:33
  • Hi, did you manage to solve this? I have a similar problem... – deivid Feb 25 '13 at 10:37
  • Ok, I got it... http://stackoverflow.com/questions/4114835/heroku-devise-missing-host-to-link-to-please-provide-host-parameter-or-set-d – deivid Feb 25 '13 at 11:20

0 Answers0