2016-10-27 23 views
0

このリンクに続くユーザーのパスワードを変更したいと考えています:Allow-users-to-edit-their-password。私は確認メールを避けるためにをuserに追加しましたが、動作しません。 は、ここに私のコードです:更新について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

関連する問題