Gem 请问在 Devise 中,在注册时如何重复确认某个字段。

whitecrow · 2012年07月23日 · 最后由 whitecrow 回复于 2012年07月23日 · 1724 次阅读

比如密码,很多网站在注册时,要求再次输入密码。如果是其它字段,又比如 Email,该如何做呢?

增加一些验证可以实现吧。

validate :reqired_active_code,:on => :create

def reqired_active_code

    if ("010345782"!= @_active_code) then
      errors.add(:active_code, "企业激活码不正确")
    end
  end

@jimrokliu 非常非常感谢 :)

需要 登录 后方可回复, 如果你还没有账号请 注册新账号