Understanding Rails validation: what does allow_blank do?

后端 未结 6 1820
一个人的身影
一个人的身影 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:21

    The following distinction can be useful to know:

    presence: true                    # nil and empty string fail validation
    presence: true, allow_blank: true # nil fails validation, empty string passes
    

提交回复
热议问题