[英]Devise user#skip_confirmation_notification! not work
I want to change the user's password following this link: Allow-users-to-edit-their-password . 我想通过此链接更改用户密码: Allow-users-to-edit-their-password 。 I've added
skip_confirmation_notification
to user
to avoid confirmation email but it doesn't work. 我已经向
user
添加了skip_confirmation_notification
以避免确认电子邮件,但是它不起作用。 Here's my code: 这是我的代码:
def update_password
@user = User.find(params[:id])
@user.skip_confirmation_notification!
if @user.update(user_password_params)
flash.notice = 'Password was successfully updated.'
else
flash.alert = @user.errors.full_messages.join('<br/>')
end
render "show_update_password"
end
private
def user_password_params
params.require(:user).permit(:password, :password_confirmation)
end
For updates you can stick with update_attributes, or just a plain save and skip_reconfirmation!
对于更新,您可以坚持使用update_attributes,或者只是简单地保存并
skip_reconfirmation!
(note the 're' in reconfirmation). (请注意再次确认)。
def update_password
@user = User.find(params[:id])
@user.skip_reconfirmation!
if @user.update(user_password_params)
flash.notice = 'Password was successfully updated.'
else
flash.alert = @user.errror.full_messages.join('<br/>')
end
render "show_update_password"
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.