I have finished Chapter 6 of railstutorial but all my User model specs have started failing soon after I added password
& password_confirmation
I think the accepted answer, to add
attr_accessor :password, :password_confirmation
for User model is wrong. Because if has_secure_password
creates those attributes virtually, that means it does it for some reason (security). So solution might be to invoke BCrypt wherever you create a User test object:
require 'bcrypt'
@user = User.new(name: 'test', password: BCrypt::Password.create("my password"), password_confirmation: 'my password')
I wrote about this on this post:
Rails - Unknown attribute password
Please correct me if I am wrong.