I've successfully set up Devise Confirmable with Facebook authentication, and everything works perfectly in development mode. When I push to heroku and run in production mode, the app send an email but the link routes me to:
http://localhost:3000/users/confirmation?confirmation_token=E2jH_ehmHwqy2zyvJGcs
If I replace localhost:3000 with my app name everything works.
In my config/environments/production.rb file I have the following code:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => ENV["GMAIL_USERNAME"],
:password => ENV["GMAIL_PASSWORD"],
:authentication => :plain,
:enable_starttls_auto => true
}
config.action_mailer.default_url_options = { :host => 'http://myapp.herokuapp.com' }
And in my development I have:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'http://localhost:3000' }
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => ENV["GMAIL_USERNAME"],
:password => ENV["GMAIL_PASSWORD"],
:authentication => :plain,
:enable_starttls_auto => true
}
Any thoughts on what to do? I couldn't find a straight answer anywhere.
I'm using rails 4 & Devise 3.2.4
The host value is being over written somewhere in your application. Good place to start with is your initializers directory. Like mentioned elsewhere, check setup_mail.rb under initializers.
Goto Rails console and check the output of:
ActionMailer::Base.default_url_options[:host]