Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

As the title implies, I'm getting this error when I try to use link_to in my mailer templates:

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

I tried to follow it's instructions, and I also found this post, but I'm still getting the error.

I've tried adding config.action_mailer.default_url_options = { host: 'example.com' } to each of the following files and none of them worked:

/config/environment.rb /config/application.rb (inside the module for my app) /config/development.rb (I'm in development mode) 

Has something changed in Rails 4 that makes this work differently?

like image 373
emersonthis Avatar asked Sep 11 '13 13:09

emersonthis


1 Answers

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

like image 138
dax Avatar answered Sep 20 '22 00:09

dax