I have successfully set up the Devise 4.2 'recoverable' module using Rails 4.2.7.1. The user experience is as follows:
- A user comes to the site, goes to a login page, clicks "Help, I Forgot My Password."
- The user is sent to a subsequent page where they enter their email address. If the address is accepted, they are sent, via email (let's call this the 'recovery email'), a link to a place where they can go to reset their password.
The problem I have is in the body of the recovery email. Everything in it works! However the link to my website omits the 'www' in the website name, causing the page linked to to display the following error:
This site can’t be reached example.com’s server DNS address could not be found. ERR_NAME_NOT_RESOLVED
If I follow the link in the body of that email to the page, I will get that error.
The link generated is http://example.com/admin/users/password/edit.10?reset_password_token=NfGEHb3z6uF7qPyqd79V
Curiously, if I add "www" manually to the address bar of this error page, everything works great. That is, the following works:
http://www.example.com/admin/users/password/edit.10?reset_password_token=NfGEHb3z6uF7qPyqd79V
It also works if I delete all but the following:
http://example.com/admin/
Note in that case I omitted the 'www', but it still worked.
Here is the code to the recovery email:
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_admin_user_password_url(@resource, :reset_password_token => @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
Here's an excerpt from routes.rb, if relevant:
root :to => 'pages#index'
devise_for :users, {:class_name => "User", :module => :devise, :controllers => { :sessions => "admin/sessions" } }
resources :users
namespace :admin do
devise_for :users, {:class_name => "User", :module => :devise, :controllers => { :sessions => "admin/sessions" } }
resources :users, :properties, :locations, :pages, :companies, :islands, :tags, :property_types, :articles, :announcements, :features
resources :agents, :controller => "users"
resources :administrators, :controller => "users"
resources :superadmins, :controller => "users"
resources :photos do
collection do
delete 'destroy_multiple'
end
end
end
Some possibly unrelated details:
- The site is hosted on Heroku.
- My email client for testing was GMail.
- The DNS and domain-stuff are AWS Route 53.
Might anyone have any idea what I am doing wrong?