“电子邮件已经被占用"用户使用 client_side_validations 登录并设计时出错 [英] "Email is already taken" error when user logs in with client_side_validations and devise

查看:25
本文介绍了“电子邮件已经被占用"用户使用 client_side_validations 登录并设计时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的 Rails 应用程序中同时使用 client_side_validations 和 devise,但在登录表单中遇到了一个奇怪的错误.

I am trying to use both client_side_validations and devise in my Rails app, and get a weird bug in the log in form.

据说电子邮件已经被占用,并且不允许用户登录:)电子邮件用作登录.

It's says that the email has already been taken and doesn't let the user to log in :) Email is used as the login.

这仅在我设置 :validate => true 时.当我关闭设置:validate => true时,登录成功.

This is only when I set the :validate => true. When I turn off the setting :validate => true, the log in is performed successfully.

可能导致此问题的原因是什么?

What might cause this problem?

推荐答案

我从 client_side_validations 的作者那里得到了答案:

I got the answer from the author of the client_side_validations:

对于登录表单,您不想拥有唯一性验证器.因此,您需要执行以下操作:

For login form you don't want to have the uniqueness validator. So you'll need to do something like:

f.text_field :email, :validate => { :uniqueness => false }

据我所知,这是一种解决方法,因为设计中的条件验证.

From what I've understood this is the workaround because of the conditional validations in devise.

这篇关于“电子邮件已经被占用"用户使用 client_side_validations 登录并设计时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆