26 Aug 2009, 15:24
Generic-user-small

James West (98 posts)

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.

Thanks

28 Aug 2009, 04:35
Generic-user-small

James West (98 posts)

OK, This is what /I have found out. The password field is NOT being populated from the database at all. It is however being populated by the browser. Is there any way that this can be prevented or have the password_confirmation input auto populated as well?

  You must be logged in to comment