Authentication Question

Hi,

I am working on some basic authentication for a Rails project. Here is
my User.rb file:

====== ====== ====== ====== ====== ======

class User < ActiveRecord::Base

attr_reader :password
attr_accessor :password_confirmation

validates_presence_of :name, :username
validates_presence_of :password, :password_confirmation
validates_confirmation_of :password

def password=(pwd)
self.password_salt = “salt”
self.password_hash = “hash”
end

end

====== ====== ====== ====== ====== ======

When I try to submit the form to create a new user, I always get a
“Password doesn’t match confirmation” error. The password field on my
form becomes blank, but the password_confirmation field maintains the
password from the previous form submission. The only way to avoid this
is the remove the password=(pwd) function. What am I doing wrong?

Fixed. Adding this line to my password= function did the trick:

@password = pwd