Kind of confused about why this happened.

Initially, my "players" table had a column named "password".  While
learning about hashing, I had a model similar to the above, except the
before_create looked like this:

  self.password = Player.hashed_password(self.password)

When I saved a player, I always got null in the password in the
database.

But, if I set the hashed_password into some other attribute
(self.last_name, let's say), I ended up with a hash value in the
last_name column.

So all I did was to drop and create the table with the column called
"hashed_password" instead, and updated the model as attached, and off I
went.

I don't understand why the 'password' column kept getting nulled
initially, though.  I expected it would act like java; a reference to
the password attribute (string) would be passed into the hashed_password
method, which would return a reference to a new string, which I would
happen to assign to the hashed_password attribute.

Can anyone shed a little light on what's under the covers?  Just a
curiousity question, it's all good after the rename.

Attachments:
http://www.ruby-forum.com/attachment/2981/player.rb

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to