well, here I am again :)

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


<p><label for="email">Email</label><br/>
<%= text_field 'user', 'email'  %></p>

<p><label for="screen_name">Screen Name</label><br/>
<%= text_field 'user', 'screen_name'  %></p>

<p><label for="first_name">First Name</label><br/>
<%= text_field 'user', 'first_name'  %></p>

<p><label for="last_name">Last Name</label><br/>
<%= text_field 'user', 'last_name'  %></p>


<p><label for="password">Password</label><br/>
<%= password_field 'user', 'password'  %></p>

<p><label for="password_confirmation">Password Confirmation</label><br/>
<%= password_field 'user', 'password_confirmation'%></p>


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

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