尝试向用户发送电子邮件以重置其密码时,我不断收到执行超时错误。其他邮件功能有效,所以我知道配置设置是正确的。标题为:“Timeout::Error in Password resetsController#create”
这是密码重置控制器:
def create
@user = User.find_by_email(params[:email])
if @user
User.deliver_password_reset_instructions(@user.id)
flash[:notice] = "Instructions to reset your password have been emailed to you. " +
"Please check your email."
redirect_to '/'
else
flash[:notice] = "No user was found with that email address"
render :action => :new
end
end
这是 User.rb 里面的方法
def self.deliver_password_reset_instructions(user_id)
user = User.find(user_id)
user.reset_perishable_token!
Emailer.deliver_password_reset_instructions(user)
end
最后,这是 emailer.rb 中的实际方法:
default_url_options[:host] = "http://0.0.0.0:3000" #development
def password_reset_instructions(user)
@subject = "Application Password Reset"
@from = 'Notice@myApp.com'
@recipients = user.email
@sent_on = Time.now
@body["edit_password_reset_url"] = edit_password_reset_url(user.perishable_token)
@headers["X-SMTPAPI"] = "{\"category\" : \"Password Recovery\"}"#send grid category header
end
为什么错误消息中的“密码”提到导致超时::错误