In the section adding users the password and password confirmation fields are set up as virtual attributes of the /User model ` attr_accessor :password_confirmation
‘password’ is a virtual attribute
def password @password end def password=(pwd) @password = pwd return if pwd.blank? create_new_salt self.hashed_password = User.encrypted_password(self.password, self.salt) end`
I’m wanting to know how the password gets populated from the database after a find for the edit view. What I would like to do is set the password_confirmation attribute to be the same as the password value when rendering the edit view so that the password_confirmtion does not need to be re-entered if attributes other than passwords are changed on an existing user. If I could understand ow the password is populated after a user record is read in then perhaps that would give me a clue as to how to achieve this but the book does not seem to explain anywhere how this is done.