2016-10-27 3 views
0

Allow-users-to-edit-their-password 다음 사용자의 암호를 변경하고 싶습니다. 확인 이메일을 피하기 위해 에 skip_confirmation_notification을 추가했지만 작동하지 않습니다. 업데이트Devise 사용자 # skip_confirmation_notification! 작동하지 않음

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 

답변

1

당신이 update_attributes을 고수 할 수 있습니다, 아니면 그냥 일반 저장하고 skip_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 

확인 Doc