I have to check if confirm_password input box exists in form.
If it exists,
I need to do this:
validates :password,:confirmation=>true
else
set confirmation to false.
Detail explanation for the problem:
I'm using rails client_side_validation gem which converts models validation into javascript form validation.
There is a little problem with this as login and sign up belongs to same table both of them have one Model. Now when I'm adding this in model for validation:
validates :password,:confirmation=>true
It will not let me to login as validation will become false as there is no confirm_password input box on login.It will only work on signup.
Assuming a model User add @user.is_signup = true
to the signup action in users_controller. In your User model add attribute_accessor :is_signup
and validates :confirm_password, :confirmation => true, :if => :is_signup
.