In Rails 3, how can I skip validation of the password field when I'm not attempting to update the password?

后端 未结 5 428
臣服心动
臣服心动 2020-12-05 10:31

My User model contains :name, :email, and :password fields. All 3 have validations for length. An \"update account\" web page allows the user to update his name and email

5条回答
  •  忘掉有多难
    2020-12-05 11:32

    When password is added then only confirmation will be called and presence will call on create action only   
    
       **validates_presence_of :password, :on =>:create**
    
       **validates_confirmation_of :password**
    

提交回复
热议问题