Reset password by email with devise in Rails

--

To reset the password by email instead of the username, we need to change the setting in config/initializers/devise.rb and app/models/user.rb.

First of all, please enable the recoverable in app/models/user.rb. For example:

 devise :database_authenticatable, :registerable, :trackable,
:rememberable, :recoverable, :validatable

Moreover, please make sure you have this line in config/initializers/devise.rb:

config.reset_password_keys = [:email]

If you want to use the username to reset the password, then you use:

config.reset_password_keys = [:username]

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Tzung-Chien Hsieh
Tzung-Chien Hsieh

Written by Tzung-Chien Hsieh

PhD in Computer Science, I will share what I learned in Programming, Machine Learning, and Rare Disorders.

No responses yet

Write a response