Created
January 10, 2014 10:15
-
-
Save xd547/8349593 to your computer and use it in GitHub Desktop.
Rails model 验证唯一,但不包含相应属性为空的情况
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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