我有一个登录表单,其中有一个忘记密码链接,当我们点击时,会出现一个Modal弹出窗口,我们输入我们的电子邮件地址。 当我们输入正确/现有的电子邮件但是如果我们输入任何错误的电子邮件或者电子邮件在数据库中不存在时,它就没有问题了 任何错误信息。请帮忙。
我尝试使用OutOfMemoryError
但没有用。我认为我们必须使用jQuery / javascript功能才能显示错误。但如何展示
模特本身?
这是我的观点:
System.exit(1)
答案 0 :(得分:0)
<%= f.inputs do %>
<%= f.input :email, :label => 'Your email address', :placeholder => "Enter your email...", :'data-validate' => '/users/checkemail'%>
<% end %>
<p id="email_search" class='email_error' style="display: none;">Email not found</p>
$(function() {
var msgp = document.getElementById('email_search');
$('[data-validate]').blur(function() {
$this = $(this);
$.get($this.data('validate'), {
email: $this.val()
}).success(function() {
$this.removeClass('field_with_errors');
msgp.style['display'] = 'none';
}).error(function() {
$this.addClass('field_with_errors');
msgp.style['display'] = 'block';
});
});
});
In users controller:
def checkemail
if params[:email] == ""
render :nothing => true, :status => 200
elsif User.where('email = ?', params[:email]).count == 0
render :nothing => true, :status => 409
else
render :nothing => true, :status => 200
end
return
end