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);
});
};
};