Forum: Ruby validates_confirmation_of not working

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A00673345921ae8c2e5570d1bd48b2e2?d=identicon&s=25 J. mp (lerias)
on 2007-02-11 00:41
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,
  validates_confirmation_of :password
  validates_presence_of :email, :first_name, :last_name, :screen_name,
                    :with =>
                    :on => :create,
                    :message=>"has an invalid format")
  #validates the uniqueness of email and screen name
  validates_uniqueness_of :email, :screen_name


  def before_create"password set to:"+password)
    salt = [ {rand(256).chr}.join].pack("m").chomp
    self.password_salt, self.password_hash =
      salt, Digest::SHA256.hexdigest(password+salt)


  #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) !=

        raise "UserName or password invalid"



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 :(
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (austin)
on 2007-02-11 01:09
(Received via mailing list)
On 2/10/07, J. mp <> 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 and the
comp.lang.ruby newsgroup); you're more likely to get a useful topical
answer to Rails questions on the proper Rails fora.

This topic is locked and can not be replied to.