Christina
Christina

Reputation: 255

Devise - forgot password - no route matches [GET] "/users/password"

I just implemented the password reset function via devise but after following the link I receive per email and resetting my password I get the following error:

No route matches [GET] "/users/password" (Routing Error)

I would assume the routing works through devise?

My code in routes.rb looks like this:

  devise_for :users, controllers: {
           sessions: 'users/sessions',
           passwords: 'users/passwords',
           registrations: 'users/registrations'
         }

I didn't change anything under controllers > users > passwords_controller.rb but in case it's helpful to see it, it looks like this:

class Users::PasswordsController < Devise::PasswordsController
  # GET /resource/password/new
  # def new
  #   super
  # end

  # POST /resource/password
  # def create
  #   super
  # end

  # GET /resource/password/edit?reset_password_token=abcdef
  # def edit
  #   super
  # end

  # PUT /resource/password
  # def update
  #   super
  # end

  # protected

  # def after_resetting_password_path_for(resource)
  #   super(resource)
  # end

  # The path used after sending reset password instructions
  # def after_sending_reset_password_instructions_path_for(resource_name)
  #   super(resource_name)
  # end
end

Am I missing anything or did I do something wrong?

When I add "get 'users/password'" to routes.rb, I get the error:

The action 'password' could not be found for UsersController (Unknown action)

Any help would be highly appreciated!

Upvotes: 0

Views: 2231

Answers (2)

Karoid
Karoid

Reputation: 789

I had same issue and couldn't find any solution. There can be two reasons for this error

  1. there is no rails-ujs (or jquer-ujs) javascript file working on this page

  2. no recoverable in User model

But in my case, there was no problem with these two, and password was changed after error page so I fixed this error by adding line in routes.rb as follows:

Rails.application.routes.draw do
  get 'users/password', to: redirect("/")
end

Upvotes: 2

Umar Khan
Umar Khan

Reputation: 1430

Make sure that you have recoverable in User model:

class User
  devise :database_authenticatable,
         :registerable,
         :validatable,
         :recoverable
end

Please let me know if it does not help you.

Upvotes: 1

Related Questions