[英]undefined method `succesfully_sent?'' , Rails 4 and Devise password recovery
My goal is to request password recovery using Ajax. 我的目标是请求使用Ajax恢复密码。
My form: 我的表格:
<%= form_for(resource,:html => {"data-parsley-validate" => true,:id=>"password-recover-modal",:class=>"password-recover-modal"},:remote=> true,format: :json,as: resource_name, url: password_path(resource_name)) do |f| %>
<div class="form-group">
<%= f.email_field :email, autofocus: true ,:class=> "user-input form-control", :id=>"email",:placeholder=>"E-pasts",required: true%>
</div>
<%= f.submit "Atgūt paroli",:class=> "blue-button btn btn-default"%>
<%end%>
I had to override Devise passwords controller: 我不得不重写Devise密码控制器:
class PasswordsController < Devise::PasswordsController
respond_to :json, only: [:create]
def create
user = resource_class.send_reset_password_instructions(resource_params)
if succesfully_sent?(user)
render json: { data: "something" }, status: 200
else
render json: { data: "something bad" }, status: 400
end
end
end
E-mail with password recovery instructions was sent successfully. 包含密码恢复说明的电子邮件已成功发送。
Problem: 问题:
I can't get ajax response either there was error sending that e-mail or not. 发送该电子邮件是否出错,我都无法获得Ajax响应。
Eror message: 错误讯息:
undefined method `succesfully_sent'
Looks like a simple typo. 看起来像是一个简单的错字。
The method is successfully_sent?
该方法
successfully_sent?
and is defined in the DeviseController
so should be available to any controller that inherits from it. 并且在
DeviseController
定义,因此任何继承自它的控制器都应可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.