Rails model validation on create and update only

前端 未结 3 774
不思量自难忘°
不思量自难忘° 2020-12-08 09:04

If I want to have validation only on create, then I can do

validates_presence_of :password, :on => :create
<         


        
3条回答
  •  一个人的身影
    2020-12-08 09:55

    By default, the validations run for both create and update. So it should be just:

    validates_presence_of :password
    

    The :on key just allows you to choose one of them.

提交回复
热议问题