I created a basic API with Ruby on Rails. Whenever I try to send data from a form in AngularJS, I get this message in the Rails Server:
Parameters: {"{\"content\":\"message\"}"=>nil} So, it's creating null records in the DB.
This is the controller in AngularJS to send the data:
app.controller('postController', function($scope, $http) { // create a blank object to handle form data. $scope.message = {}; // calling submit function. $scope.submitForm = function() { $http({ method : 'POST', url : 'http://localhost:3000/api/v1/messages', data : $scope.message, //forms user object headers : {'Content-Type': 'application/x-www-form-urlencoded'} }) .success(function(data) { ... } }); }; });
$scope.messagebefore you POST? What if you remove the content type?