plataformatec/devise — Issue #1510: 'Forgot your password' email link appears to read Action Mailer default host in development environment, even when environment is production
Author: jhdavids8
Created: 2011-12-15 00:39:37+00:00
State: open

This was brought up here: http://stackoverflow.com/questions/7897495/devise-forgot-password-is-creating-a-link-with-locahost-on-product

I just saw the issue today myself. In my development env config, I had the following line of code:
config.action_mailer.default_url_options = { :host => 'localhost' }
And in my production env config, I had this:
config.action_mailer.default_url_options = {:host => 'mysite.com'}

In development and production, when the 'forgot your password' email was sent, the 'Change my password' link in the email would link to http://localhost/users/password/edit?reset_password_token=xxx.

I had to remove the action_mailer.default_url_options from development.rb in order for it to work correctly in production. So it appears that Devise would first look if the default url was set in development. If not, then it would look in production. Or maybe I'm crazy??