I keep getting:
Can't verify CSRF token authenticity Completed 422 Unprocessable Entity in 2ms (ActiveRecord: 0.0ms)
I am trying to make an $http request to post a new db entry. Using Angular over RoR.
inside my Angular controller:
...
$scope.createArea = function(data){
var areaData = $scope.areaData;
var url = '/locations/' + locationService.id + '/floors/' + floorService.id + '/areas.json'
$http({
url: url,
method: 'POST',
contentType: "application/json",
data: areaData
});
};
my form:
<div class="form-horizontal" id="new-area" ng-controller="mapsController">
<form ng-submit="createArea(areaData)">
<div id="name-group" class="form-group">
<label>Name</label>
<input type="text" name="name" class="form-control" placeholder="Area Name" ng-model="areaData.name" /><br />
<label>Group</label>
<select class="form-control">
<option ng-repeat="group in groups" value="{{group.id}}" ng-model="areaData.groupID">{{group.name}}</option>
</select>
</div>
<button type="submit" class="btn btn-default">Create</button>
</form>
</div>
in my rails controller:
def create
respond_to do |format|
format.json
end
end