比较新的写法是：
validates :username, presence: true, uniqueness: true, length: { :minimum => 2, maximum => 50}