ActionView::Template::Error: Missing host to link to

I ran into this problem the other day and this is what ended up working for me:

Rails.application.routes.default_url_options[:host] = '???'

edit

This goes in each environment file - development.rb, test.rb and production.rb (and more if you have them) with the corresponding host name in each one


You've to set the default_url in each environment(development, test, production).

You need make these changes.

    config/environments/development.rb
     config.action_mailer.default_url_options = 
      { :host => 'your-host-name' }  #if it is local then 'localhost:3000'

 config/environments/test.rb
      config.action_mailer.default_url_options = 
      { :host => 'your-host-name' }  #if it is local then 'localhost:3000'

  config/environments/production.rb
     config.action_mailer.default_url_options = 
      { :host => 'your-host-name' }  #if it is local then 'localhost:3000'