我正在尝试使用Restangular删除用户。在服务器上收到
Started DELETE "/users/9" for 127.0.0.1 at 2015-11-25 22:56:47 +0300
Processing by UsersController#destroy as HTML
Parameters: {"id"=>"9"}
Can't verify CSRF token authenticity
但是,在PUT请求和其他错误发生时,只有DELETE
Started PUT "/users/9" for 127.0.0.1 at 2015-11-25 23:08:14 +0300
Processing by UsersController#update as */*
Parameters: {"user"=>{"surname"=>"белозоров", "name"=>"helasdf", "patronymic"=>"asdfadf", "login"=>"login123123", "role_id"=>"1"}, "id"=>"9"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
usersController
$scope.deleteUser = function(user){
user.remove().then(
function(){
$scope.users = _.without($scope.users, user);
alertify.success("Пользователь удален!");
},
function() {
alertify.error("Не удалось удалить пользователя. Подробности неизвестны");
}
);
};
答案 0 :(得分:0)
如果您使用的是rails 4.1及更高版本,则必须使用表单提交PUT和DELETE请求