Validates_confirmation_of not working - now in right place

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:

J. mp wrote:

well, here I am again :slight_smile:

validates_confirmation_of is not working

<%= password_field ‘user’, ‘password’ %>

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

just to add a logger info

Parameters: {“user”=>{“password_confirmation”=>“12922eddsd”,
“screen_name”=>“kdskdk”, “first_name”=>“kdskk”, “last_name”=>“dskkd”,
“password”=>“skdks”, “email”=>“[email protected]”}, “commit”=>“Create”,
“action”=>“add_user”, “controller”=>“admin/user”}

it is the the request, but not working :frowning:

J. mp wrote:

J. mp wrote:

well, here I am again :slight_smile:

validates_confirmation_of is not working

<%= password_field ‘user’, ‘password’ %>

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

just to add a logger info

Parameters: {“user”=>{“password_confirmation”=>“12922eddsd”,
“screen_name”=>“kdskdk”, “first_name”=>“kdskk”, “last_name”=>“dskkd”,
“password”=>“skdks”, “email”=>“[email protected]”}, “commit”=>“Create”,
“action”=>“add_user”, “controller”=>“admin/user”}

it is the the request, but not working :frowning:

thanks all,
found the problem :slight_smile: and the solution:

attr_accessible :email, :first_name, :last_name, :screen_name,
:password,:password_confirmation

missedthe password_conmfirmation on attr_accessible list :slight_smile:

On Sun, 11 Feb 2007, J. mp wrote:

well, here I am again :slight_smile:

validates_confirmation_of is not working

What does the code look like where you create the new user record?

David


Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
(See what readers are saying! http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)

unknown wrote:

On Sun, 11 Feb 2007, J. mp wrote:

well, here I am again :slight_smile:

validates_confirmation_of is not working

What does the code look like where you create the new user record?

David


Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
(See what readers are saying! http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)

thanks David but I already realized the problem:
missed the password_conmfirmation on attr_accessible list :slight_smile:

On Sat, 10 Feb 2007, [email protected] wrote:

On Sun, 11 Feb 2007, J. mp wrote:

well, here I am again :slight_smile:

validates_confirmation_of is not working

What does the code look like where you create the new user record?

Never mind – I just saw that you found the problem :slight_smile:

David


Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
(See what readers are saying! http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)