# frozen_string_literal: true
class Setting < ApplicationRecord
RESERVED_SUBDOMAINS = %w(www apps support blogs)
validates :subdomain, presence: true, uniqueness: true
validates :subdomain, format: /\A[a-z]+[a-z\d\-]*\z/
validates :subdomain, exclusion: { in: RESERVED_SUBDOMAINS, message: 'That subdomain is not available. Please choose another.' }
end
如果对子域的验证失败,是否可以运行自定义方法?我想在验证失败后运行自定义方法的原因是,我想自动生成一个子域并保存在数据库中。