jeudi 18 octobre 2018

Skip uniqueness validation for nil class Rails 3

Currently I can't create empty field with nil value, because nil counts as unique. I want to do if field have value then it must be unique, if nil then not and also it can't return empty string value.

This is my validation:

validates :subdomain, :allow_nil => true, uniqueness: true

Aucun commentaire:

Enregistrer un commentaire