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

<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 :frowning:

···

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

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

···

On 2/10/07, J. mp <joaomiguel.pereira@gmail.com> wrote:

validates_confirmation_of is not working

--
Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/
               * austin@halostatue.ca * You are in a maze of twisty little passages, all alike. // halo • statue
               * austin@zieglers.ca