Feb 22 2014

Rails Error: Using Devise, I was getting “Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true”

I’ve been learning Rails for awhile now and I just recently started using Devise for user authentication. It’s been great until I got stuck on the following Error:

ArgumentError in Devise::Passwords#create

Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
Extracted source (around line #5):

Someone has requested a link to change your password. You can do this through the link below.

<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @token) %>

If you didn’t request this, please ignore this email.

Your password won’t change until you access the link above and create a new one.

I spent some time on Google and none of the solutions I found seemed to work at all. I was getting frustrated so I ran some updates and rebooted and sure enough, when I restarted the rails server the emails worked. It would appear the config methods in the environment files don’t reload unless the server is restarted. Hopefully this is helpful to anyone else who is going through the same thing.

The code that finally worked for me in my development.rb file (after I rebooted) was:


  config.assets.debug = true
  config.action_mailer.delivery_method = :sendmail
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default_options = {from: 'mailer@domain.net'}
  config.action_mailer.default_url_options = {:host => "localhost:3000"}

I am using sendmail. For using smtp check The Ruby Docs

Share