Topic: Populate existing records after you have added a password_digest col?
I am using rails 3.1.3 and ruby 1.9.3-p0 with postgresql 9.1.
I am trying to refactor the authentication system that I have in place after following the railstutorial.org screencasts.
My first problem was that I had existing records so how do I populate these records after I have added the password_digest column to my employee table. I found railsguides, 'Migrations', and it did have an example.
The example deals with adding a, receive_newsletter, column to their users table which they set to 'false' as default.
Then they use the following:
User.update_all ["receive_newsletter = ?", true]
as a means to update existing records to a setting of true.
I thought that this must be it, but then:
Employee.update_all ["password_digest = ?", not sure what to put here]
As you can see I ran out of steam very quickly since I do not know how to inform password_digest to take password and to act upon it such that it is encrypted, and has a 'salt' and then to save it in password_digest. Also, I am not sure if I have to run a new migration that focuses on the update alone, or do I rollback the addition of the password_digest column and then add the update to the migration that adds the column?
Does anyone have an idea, or suggestion or a resource they can point me too, such that I can resolve this issue?