validates_confirmation_of and hashed password fields

How do I use forms and validates_confirmation_of with fields that aren't actually in the model? For instance, user passwords are stored in the database as password_hash and password_salt. The field "password" isn't actually in the table, but comes in from the form and is set to the model using a def password=() method.

When using password_field or password_field_tag in the view for the user sign up form, I get an exception that no method exists for "password" (since it's not in the model)? I got around this by adding

def password @password end

To the model, but then validates_confirmation_of will not work (always says fields don't match). How do I properly set this up to handle the "password" field so that I can use it in forms and use the validation features on it?

Thanks

Seem to have solved the problem with this line in the User model:

attr_accessor :password

Assuming this is the right practice for these types of fields... let me know if I'm wrong or if there's a more appropriate way