Validates_confirmation_of not working

well, here I am again :slight_smile:

validates_confirmation_of is not working

heres my model

class User < ActiveRecord::Base
attr_accessor :password
attr_accessible :email, :first_name, :last_name, :screen_name,
:password
validates_confirmation_of :password
validates_presence_of :email, :first_name, :last_name, :screen_name,
:password
validates_format_of(:email,
:with =>
/^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i,
:on => :create,
:message=>“has an invalid format”)
#validates the uniqueness of email and screen name
validates_uniqueness_of :email, :screen_name

#end

def before_create
logger.info(“password set to:”+password)
salt = [Array.new(6) {rand(256).chr}.join].pack(“m”).chomp
self.password_salt, self.password_hash =
salt, Digest::SHA256.hexdigest(password+salt)

end

#Authenticate a user
def self.authenticate(email, password)

user = User.find(:first, :conditions => ['email = ?', email])
 if user.blank? ||
    Digest::SHA256.hexdigest(password+ user.password_salt) !=

user.password_hash

    raise "UserName or password invalid"
 end
 user

end

end

and my view

Email
<%= text_field 'user', 'email' %>

Screen Name
<%= text_field 'user', 'screen_name' %>

First Name
<%= text_field 'user', 'first_name' %>

Last Name
<%= text_field 'user', 'last_name' %>

Password
<%= password_field 'user', 'password' %>

Password Confirmation
<%= password_field 'user', 'password_confirmation'%>

however if I set differnt passwords in user creation it let me save the
user :frowning:

On 2/10/07, J. mp [email protected] wrote:

validates_confirmation_of is not working

This is a rails-specific question asked on the general Ruby mailing
list (which is bidirectionally mirrored to ruby-forum.com and the
comp.lang.ruby newsgroup); you’re more likely to get a useful topical
answer to Rails questions on the proper Rails fora.

-austin