Understanding Rails validation: what does allow_blank do?

后端 未结 6 1821
一个人的身影
一个人的身影 2020-12-09 01:15

I\'m quite new to Rails and found a little snippet to validate presence and uniqueness step by step: first check presence, then check uniqueness.

validates :         


        
6条回答
  •  情书的邮戳
    2020-12-09 02:18

    :allow_blank is an option that will "disable" several of the validators, but not the presence validator. The result of using these two together is that when the field is left blank, you will get the :blank error message (i.e., "can't be blank"), but not the other error messages.

提交回复
热议问题