I need to selectively turn off validations for example, I want to make sure that password and password_confirmation fields are equal when user first signs up or changes his password from his profile, but not in other cases e.g. updates his profile.
right now I am using a quick and dirty hack by using booleans e.g. if(@skip_password_validations != false) #--do validations --#
is there anything better than this. any help would be greatly appreciated.
I need to selectively turn off validations for example, I
want to
make sure that password and password_confirmation fields are equal
when user
first signs up or changes his password from his profile, but not in
other
cases e.g. updates his profile.
right now I am using a quick and dirty hack by using booleans
e.g.
if(@skip_password_validations != false) #--do validations --#
is there anything better than this. any help would be greatly
appreciated.
def skip_password_validations?
@skip_password_validations
end
or even
with_options :unless => skip_password_validations? do
validates_presence_of :password
validates_presence_of :password_confirmation
validates_confirmation_of :password
end