Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
validates_confirmation_of :password not working for me help me
2 Posts
validates_confirmation_of :password not working for me help me

Hi all

Im working on "password_confirmation".

for me validations "validates_format_of","validates_presence_of" and "validates_uniqueness_of" working.

Only "password_confirmation" is not working.

Please help me in this issue..

my form code is...........

Im Using Custom Form Builder in below file...

h1>User Registration ......

register_users_path,:update=>'MB_frame', :builder => TaggedBuilder do|f| %>

 <tr></tr>

    <tr></tr>

    <tr></tr>
    <tr></tr>
    <tr></tr>   

&nbsp&nbsp&nbspClose

============================================================================ controller's code is

def register if request.post?

 @user = User.save_user(params[:user]) 

end

end

my model code is ............

require 'fileutils' require 'digest/sha2'

class User < ActiveRecord::Base validates_uniqueness_of :email,

                         :on => :create,
                         :message=>"alredy taken"

 validates_format_of :email,
                    :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-2,})$/i,
                    :message => "Its not a valid format"

attr_accessor :password_confirmation validates_confirmation_of :password

validates_presence_of :name,:email,:password

def self.save_user(params)

@u=User.find_by_email(params['email'])
u=User.new
u.name=params['name']
u.email=params['email']
if !params['password'].empty? && @u==nil
u.password=Digest::SHA256.hexdigest(params['password']) 
end
u.role_id=1
u.save

return u

end

With regards: ANAS

I guess this has to do with your form builder. better if u dig in to it or post it here.

2 Posts
Login to add your message