我想验证一个字符串属性不是 nil,但允许空字符串。
如:
validates name: not_nil, allow_empty: true
最佳答案
你还可以这样做:
validates :name, exclusion: { in: [nil] }
关于ruby-on-rails - 验证 Rails 属性存在但允许空字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50144825/