简体   繁体   English

使用Javascript登录设计用户注册

[英]Devise User Registration with Javascript Login

I have a working registration form with validation and all that - and some other fields for other models. 我有一个有效的注册表格,其中包含验证以及所有其他内容,以及其他模型的其他字段。 Now I need to add some client-side validation which checks the email for uniqueness. 现在,我需要添加一些客户端验证,以检查电子邮件的唯一性。 If it's taken the fields for the user model should be replaced with login fields. 如果已采取,则应将用户模型的字段替换为登录字段。

Not sure where and how to start. 不知道从哪里开始以及如何开始。

My suggestion would be to write an own method in your controller that accepts ajax calls, wich gets triggered on onblur of the email field (and of course sends the email data). 我的建议是在您的控制器中编写一个自己的方法来接受ajax调用,这将在电子邮件字段的onblur触发(当然会发送电子邮件数据)。

The controller method checks if the given email address exists in your database. 控制器方法检查给定的电子邮件地址是否存在于数据库中。 If so you can render a ERB-Javascript template which replaces your existing registration form with the login form rendered in the template. 如果是这样,您可以呈现一个ERB-Javascript模板,该模板将您现有的注册表单替换为模板中呈现的登录表单。

Hope it's clear what I mean. 希望我的意思很清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM