How to recover a password using a program (Ruby on Rails)

I am trying to recover a user password using devise, but it generates the following error:

undefined method `reset_password_sent_at=' for #<User:0x007fb78cfafb68> 

Can someone help me with this since I'm new to Ruby on Rails?

What is the best way to recover a password and send an email to a user using Devise? Thank you very much.

I am using the application (2.2.3)

User.rb

 require 'digest/md5' class User < ActiveRecord::Base # Setup accessible (or protected) attributes for your model belongs_to :shop before_create :compute_email_md5 # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable # Setup accessible (or protected) attributes for your model attr_accessible :email, :email_md5, :password, :password_confirmation, :shop_id, :role, :terms, :name, :notify_on_order_received validates :terms, :acceptance => true, :on => :create end 

SOLUTION add reset_password_sent_at column to user table

+4
source share
1 answer

As you have discovered, passport recovery requires the model to have a reset_password_sent_at column. Adding this problem through migration should solve this problem.

Due to the fact that this is happening, I assume that you have added password recovery (module :recoverable ) after the initial generation of the model with Devise (User) support. This is why the Devise generator did not create this column for you.

+5
source

All Articles