我目前正在研究Hartl的Ruby on Rails教程第3版第10章中的密码重置部分。
当我尝试重置密码时,出现以下错误:
Started POST "/password_resets" for ::1 at 2015-01-02 12:04:11 -0500
Processing by PasswordResetsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"3IzFDLnzyWl56oXiSIDgjemDC+14Hypdn2j5pUHEJVaFVFjpPVh1sxIbA7cr3CDKrMlffDw3QEwN2hI6rvmRwQ==", "password_reset"=>"[FILTERED]", "commit"=>"Submit"}
Completed 500 in 9ms
ArgumentError - wrong number of arguments (1 for 0):
在我看来,它告诉我以下代码的第8行是问题:
def create
@user = User.find_by(email: params[:password_reset][:email].downcase)
if @user
@user.create_reset_digest
@user.send_password_reset_email
flash[:info] = "Email sent with password reset instructions"
redirect_to root_url
else
flash.now[:danger] = "Email address not found"
render 'new'
end
end
以下是:
@user = User.find_by(email: params[:password_reset][:email].downcase)
我已多次查看代码,根本无法弄清楚这一个......我很难过。任何帮助将不胜感激/