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]