And then I want to validate if username is empty, email is valid email, and password is the same as confirm password, but things are not working like it should....
.... Can somebody help here, rails is giving me too much pain...I thought it was more simple then this?
Hi Jamal, I think you just add a validate method to your class and add the error in there if the 2 don't match. I found this code from the rails list archive. Maybe it will help you.
class Model < ActiveRecord::Base attr_accessor :password, :password_confirmation
def validate errors.add('password', 'Password and confirmation do not match') unless password_confirmation == password end
def before_save self.password_sha1 = Digest::SHA1(password) if password end end
from http://wrath.rubyonrails.org/pipermail/rails/2004-November/000587.html