Skip to content

Instantly share code, notes, and snippets.

@xd547
Created January 10, 2014 10:15
Show Gist options
  • Select an option

  • Save xd547/8349593 to your computer and use it in GitHub Desktop.

Select an option

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