0

I'm trying to delete a user using Restangular. On the server receives a

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

However, in the PUT request and other error occurs, only 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("Не удалось удалить пользователя. Подробности неизвестны");
            }
        );
    };
motoroller
  • 55
  • 8
  • were u able to figure out a fix for ur issue? – nowRails Dec 04 '15 at 18:40
  • sorry, I don't understand you :) – motoroller Dec 06 '15 at 13:35
  • I am limited by the information provided, U should provide error information for PUT if ur PUT req is causing errors. I hope the following link helps you. [answered link] (http://stackoverflow.com/questions/18336699/how-to-send-csrf-token-inside-angularjs-form-using-laravel-api?lq=1) – nowRails Dec 07 '15 at 19:00

1 Answers1

0

if you are using rails 4.1 and above you have to use form submits for PUT and DELETE requests

nowRails
  • 267
  • 2
  • 5
  • 1
    quick googling : http://stackoverflow.com/questions/28401978/how-do-i-save-an-angular-form-to-my-ruby-on-rails-backend – nowRails Nov 25 '15 at 20:53