We're using the standard devise forgot password mailer:
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
On production this is generating a localhost url for Change Password:
http://localhost:3000/users/password/edit?reset_password_token=amqs2q9NcM1FerHKhmzV
This is strange given the production.rb file has our domain:
config.action_mailer.default_url_options = { :host => 'mysite.com' }
Why is mysite.com not being used in the URL? Ideas?
Thanks
My guess is that config.action_mailer.default_url_options
is being overwritten somewhere. Do you have any file in config/initializers
that affects ActionMailer
?
Try running rails console
on your production box and see what
ActionMailer::Base.default_url_options[:host]
returns.
My problem was in config/initializers/setup_mail.rb
I fixed this by simply adding port
to config.action_mailer.default_url_options
which Devise always tells us to do during installation but many of us ignore it.
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
this is for development.rb
anyway.
In production the value of the port will be a variable - $PORT
, cos Heroku dynamically generates the port.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With