We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
field :code, type: String validates :code, uniqueness: { scope: :site, message: "核销码不能重复" } index code: 1 before_create :gen_code private def gen_code self.code = (0..9).to_a.sample(10).join self.valid? if self.errors[:code].any? logger.debug "重复重新生成" gen_code end end