I kept coming across this error when I ran the rails console and tried to set a user password:
NoMethodError: undefined method `password_digest=
It wasn’t written in the guide, but to solve this problem, you have to run a migration and create a new database which I called AddPasswordDigestToUsers (following Hartl’s code on Github).
$ rails generate migration AddPasswordDigestToUsers password_digest: string
Then a new file will be created with the following code written in it:
class AddPasswordDigestToUsers < ActiveRecord::Migration def change add_column :users, :password_digest, :string end end
Now, you should be able to run the $rails console and add a password to your user.
>>user = User.first
>>user.password = “fresh”