Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何使用angularjs和rails/Desive更新密码?_Ruby On Rails_Angularjs_Devise - Fatal编程技术网

Ruby on rails 如何使用angularjs和rails/Desive更新密码?

Ruby on rails 如何使用angularjs和rails/Desive更新密码?,ruby-on-rails,angularjs,devise,Ruby On Rails,Angularjs,Devise,我在尝试使用带有新旧密码的简单表单更新用户密码时遇到问题。问题是我将{“用户[当前密码]”:$scope.user.password,“用户[密码]”:$scope.user.newpassword}数据发布到我的design::RegistrationsController中,我得到了一个简单的422个不可处理的实体响应。我哪里做错了 这是我的html <div ng-controller="PasswordCtrl"> <form id="password-card

我在尝试使用带有新旧密码的简单表单更新用户密码时遇到问题。问题是我将
{“用户[当前密码]”:$scope.user.password,“用户[密码]”:$scope.user.newpassword}
数据发布到我的
design::RegistrationsController
中,我得到了一个简单的
422个不可处理的实体
响应。我哪里做错了

这是我的html

<div ng-controller="PasswordCtrl">
    <form id="password-card" class="row" style="display:none;" name="password_form" ng-submit="changePassword()" novalidate>
        <div class="span5">
            <div class="form-inputs">
                <label for="nPass"><%= I18n.t("registration.edit.current_password") %></label>
                <input name="uPass" class="required" type="password" ng-model="user.password" required >
                <div ng-show="password_form.uPass.$dirty && password_form.uPass.$invalid">Missing:
                  <span ng-show="password_form.uPass.$error.required">You must provided your current password.</span>
                </div>                    

                <label for="nPass"><%= I18n.t("registration.edit.new_password") %></label>
                <input name="nPass" class="required" type="password" ng-model="user.newpassword" required >
                <div ng-show="password_form.nPass.$dirty && password_form.nPass.$invalid">Missing:
                  <span ng-show="password_form.nPass.$error.required">Tell us your new password.</span>
                </div>                    
                <button id="x" type="submit" ng-disabled="!password_form.$valid" class="button secondary prefix">Breyta</button>
            </div>
        </div>
    </form>
</div>

您传递的数据对象无效(用户[current_password]&用户[password]):请使用引号进行尝试

数据:{“user['current_password']”:$scope.user.password,“user['password']”:$scope.user.newpassword}

var PasswordCtrl=function($scope,registrationService, $http){

    $scope.changePassword=function(){
        console.log("current_password",password_form.uPass.value);
        $http({
            method: 'PUT', 
            url: '/skraning.json', 
            headers: {'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')},
            data: {"user[current_password]":$scope.user.password,"user[password]":$scope.user.newpassword}
        }).
        success(function(data, status, headers, config) {
            console.log("done",data);
        });
    };
};