title: Expected response to contain an object but got an array
body: <p>I get this error, I found many thread with the same message, but it never seems to match my case, and I didn't manager to solve it.</p>
  
  <p>Basivally, everything was ok until I tried to make 1 form for create and update a 'Car' object.</p>
  
  <p>Here is a presentation of my app (build from this template: <a href="https://github.com/linnovate/mean">https://github.com/linnovate/mean</a>):</p>
  
  <p>/public/js/config.js:</p>
  
  <pre><code>[...]
    .state('edit car', {
      url: '/cars/:carId/edit',
      templateUrl: 'views/cars/edit.html'
  })
    .state('create car', {
      url: '/cars/create',
      templateUrl: 'views/cars/edit.html'
  })
  </code></pre>
  
  <p>/public/js/services/mycars.js (don't really know what services are used for...):</p>
  
  <pre><code>//Cars service used for car REST endpoint
  angular.module('mean.mycars').factory('Cars', ['$resource', function($resource) {
  return $resource('cars/:carId', {
      carId: '@_id'
  }, {
      update: {
          method: 'PUT'
      }
  });
  }]);
  </code></pre>
  
  <p>public/js/controllers/mycars.js:</p>
  
  <pre><code>angular.module('mean.mycars').controller('MyCarsController', ['$scope', '$http', '$stateParams', '$location', 'Global', 'Cars',
  function ($scope, $http, $stateParams, $location, Global, Cars) {
  
      $scope.findOneOrCreate = function () {
          // create a new car
          var car = new Cars({
              id : null,
              marque: this.marque,
              modele: this.modele,
              desc: this.desc
          });
  
          // put new car in scope
          $scope.car = car;
  
          // if there is a param, search for the car (mode update)
          if ($stateParams.carId !== null){
              Cars.get({
                  carId: $stateParams.carId
              }, function(carTmp) {
                         // put the result in scope
                          $scope.car = carTmp;
                      });
          }
      };
  
     $scope.createOrUpdate = function () {
          var car = $scope.car;
  
          if (car.id !== null) {
          // update
              if (!car.updated) {
                  car.updated = [];
              }
              car.updated.push(new Date().getTime());
  
              car.$update(function () {
                  $location.path('cars/' + car._id);
              });
          }
          else {
              //Create
              car.$save(function (response) {
                  $location.path('cars/' + response._id);
              });
          }
      };
  </code></pre>
  
  <p>And finally my view: edit.html:</p>
  
  <pre><code>&lt;section data-ng-controller="MyCarsController" data-ng-init="findOneOrCreate()"&gt;
      &lt;form class="form-horizontal col-md-6" role="form" data-ng-submit="createOrUpdate()"&gt;
          &lt;div class="form-group"&gt;
              &lt;label for="title" class="col-md-2 control-label"&gt;Title&lt;/label&gt;
              &lt;div class="col-md-10"&gt;
                  &lt;input type="text" class="form-control" data-ng-model="car.modele" id="title" placeholder="Title" required&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
              &lt;label for="content" class="col-md-2 control-label"&gt;Content&lt;/label&gt;
              &lt;div class="col-md-10"&gt;
                  &lt;textarea data-ng-model="car.marque" id="content" cols="30" rows="10" placeholder="Content" class="form-control" required&gt;&lt;/textarea&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
              &lt;div class="col-md-offset-2 col-md-10"&gt;
                  &lt;button type="submit" class="btn btn-default"&gt;Submit&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>Edit to add infos:
  The web Services are supposed to return only one car (but not sure if they do), here they are:</p>
  
  <pre><code>exports.car = function(req, res, next, id) {
  Car.load(id, function(err, car) {
      if (err) return next(err);
      if (!car) return next(new Error('Failed to load car ' + id));
      req.car = car;
      next();
  });
  };
  
  exports.create = function(req, res) {
  var car = new Car(req.body);
  car.user = req.user;
  
  car.save(function(err) {
      if (err) {
          return res.send('users/signup', {
              errors: err.errors,
              car: car
          });
      } else {
          res.jsonp(car);
      }
  });
  };
  
  exports.update = function(req, res) {
  var car = req.car;
  
  car = _.extend(car, req.body);
  
  car.save(function(err) {
      if (err) {
          return res.send('users/signup', {
              errors: err.errors,
              car: car
          });
      } else {
          res.jsonp(car);
      }
  });
  };
  </code></pre>
  
  <p>Error message appears when I go to /cars/create, not when I go to /cars/:carsId/edit:</p>
  
  <pre><code>Error: [$resource:badcfg] Error in resource configuration. Expected response to contain an object but got an array
  http://errors.angularjs.org/1.2.15/$resource/badcfg?p0=object&amp;p1=array
  </code></pre>