lass Person < ApplicationRecord validates_each :name, :surname do |record, attr, value| record.errors.add(attr, 'must start with upper case') if value =~ /\A[[:lower:]]/ end end
ri Regexp 有真相
ri Regexp
http://ruby-doc.org/core-2.4.2/Regexp.html 小写字母开头的字符串
嗯,明白了,多谢指点@luikore, @zaqmjuop