Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I enable :recoverable in Devise?

By default, the forgot password in Devise doesn't actually send a password reset link to email and I know the :recoverable module is what needs to be enabled/implemented.

I have tried searching for tutorials or guides in google and here in stackoverflow but no success.

Where can I find a good example or what code do I need to enable it?


1 Answers

To enable the recoverable module, pass it as a symbol to the devise method.

# in user.rb

devise :recoverable # add other modules, separated by commas

For example, your devise configuration might look something like this.

devise :database_authenticatable, :registerable, :confirmable, :recoverable

You should also add reset_password_token and reset_password_sent_at columns to your users table. You can do it with a migration.

rails g migration add_recoverable_fields_to_users

And in the generated migration file, add the following.

def change
  add_column :users, :reset_password_token, :string
  add_column :users, :reset_password_sent_at, :datetime
end
like image 121
Arun Kumar Mohan Avatar answered Dec 09 '25 13:12

Arun Kumar Mohan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!