'Devise forgot password renders wrong template

Rails 6, Devise 4.7.3 I have a forgotten password template in my views as users/passwords/new.html.erb that renders fine, collects an email, and sends that back to the Application. I also have a nice view template at users/passwords/edit that I am expecting to render when the email is sent in. In my case however, the template comes from devise/passwords/edit.html.erb which is not the one that should render.

Why is the devise template rendering and not the one I am expecting to run?

My routes:

 devise_scope :user do
    get 'sign_in', to: 'users/sessions#new'
    get 'sign_up', to: 'users/registrations#new'
    get 'forgot_password', to: 'users/passwords#new'
    get 'reset_password', to: 'users/passwords#edit'
  end

In the end, all I had to do to get MY controllers working was to add the devise_for :users route to point to { passwords: 'users/passwords' }



Solution 1:[1]

Since the devise controller is handling the password change it renders the default devise views. You can either update the devise views with your own design or create your own update_password method to overwrite the default one from devise.

You can read more on how to implement your own update password method here: https://github.com/heartcombo/devise/wiki/How-To:-Allow-users-to-edit-their-password

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Heshie Bee