Discussion Forums
- Topic List
- Most Recent Posts
- Sign In for more options
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| %>
============================================================================ 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.
