Skip to content

Instantly share code, notes, and snippets.

@xd547
Created January 10, 2014 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xd547/8349593 to your computer and use it in GitHub Desktop.
Save xd547/8349593 to your computer and use it in GitHub Desktop.
Rails model 验证唯一,但不包含相应属性为空的情况
validates :domain, uniqueness: { unless: Proc.new { |shop| shop.domain == '' or shop.domain == nil } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment