Heroku/devise - Missing host to link to! Please provide :host parameter or set default_url_options[:host] Heroku/devise - Missing host to link to! Please provide :host parameter or set default_url_options[:host] ruby-on-rails ruby-on-rails

Heroku/devise - Missing host to link to! Please provide :host parameter or set default_url_options[:host]


You need to add this to your environment.rb

  config.action_mailer.default_url_options = { :host => 'localhost' }

Make sure you change host to your production url and keep it localhost for development. This is for the mailer, it needs a default email to send out notices such as confirmations etc...


You should check the logs on the heroku server heroku logs run that from the console and it will tell you the exact error.

When you push to heroku you need to configure the environment.rb file with the heroku subdomain:

config.action_mailer.default_url_options = { :host => 'yourapp.heroku.com' }

Depending upon version, this should go in production.rb, not environment.rb.


Ok,

First you have to install the sendgrid gem with this command line:

heroku addons:add sendgrid:free

Then you just have to configure your env/dev.rb and env/prod.rb like this:

env/dev.rb

config.action_mailer.default_url_options = { :host => 'localhost:3000' }

env/prod.rb

config.action_mailer.default_url_options = { :host => 'yourapp.heroku.com' }

Push on git and heroku. It should work..


Codeglot's anwser above does the job, but we wanted something a bit more flexible, so we did this:

On Heroku, we run multiple Production environments for staging and testing, so we need a flexible solution for the production.rb environment file.

In production.rb

config.action_mailer.default_url_options = { :host => ENV['MAILER_URL'] }

Then set the MAILER_URL environment variable for your app like so

heroku config:set MAILER_URL=my-awesome-app.herokuapp.com --app my-awesome-app